From 1ea00a77522875eb0c578337527ee4ef4efac934 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Tue, 25 Feb 2025 17:47:51 +0300 Subject: [PATCH 001/984] BREAKING CHANGE: Rename Readers project to YamlReader --- .azure-pipelines/ci-build.yml | 6 +++--- Microsoft.OpenApi.sln | 2 +- src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 2 +- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 2 +- src/Microsoft.OpenApi.Workbench/MainModel.cs | 2 +- .../Microsoft.OpenApi.Workbench.csproj | 2 +- .../Microsoft.OpenApi.YamlReader.csproj} | 0 .../OpenApiYamlReader.cs | 2 +- .../Properties/AssemblyInfo.cs | 0 .../Properties/SRResource.Designer.cs | 2 +- .../Properties/SRResource.resx | 0 .../YamlConverter.cs | 2 +- .../Services/OpenApiServiceTests.cs | 2 +- .../Microsoft.OpenApi.Readers.Tests.csproj | 2 +- .../OpenApiReaderTests/OpenApiDiagnosticTests.cs | 1 + test/Microsoft.OpenApi.Readers.Tests/ParseNodeTests.cs | 2 +- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 1 + test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs | 2 +- .../Models/References/OpenApiCallbackReferenceTests.cs | 2 +- .../Models/References/OpenApiExampleReferenceTests.cs | 2 +- .../Models/References/OpenApiHeaderReferenceTests.cs | 2 +- .../Models/References/OpenApiLinkReferenceTests.cs | 2 +- .../Models/References/OpenApiParameterReferenceTests.cs | 2 +- .../Models/References/OpenApiPathItemReferenceTests.cs | 2 +- .../Models/References/OpenApiRequestBodyReferenceTests.cs | 2 +- .../Models/References/OpenApiResponseReferenceTest.cs | 2 +- .../References/OpenApiSecuritySchemeReferenceTests.cs | 2 +- .../Models/References/OpenApiTagReferenceTest.cs | 2 +- .../Microsoft.OpenApi.Trimming.Tests.csproj | 2 +- 29 files changed, 28 insertions(+), 26 deletions(-) rename src/{Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj => Microsoft.OpenApi.YamlReader/Microsoft.OpenApi.YamlReader.csproj} (100%) rename src/{Microsoft.OpenApi.Readers => Microsoft.OpenApi.YamlReader}/OpenApiYamlReader.cs (99%) rename src/{Microsoft.OpenApi.Readers => Microsoft.OpenApi.YamlReader}/Properties/AssemblyInfo.cs (100%) rename src/{Microsoft.OpenApi.Readers => Microsoft.OpenApi.YamlReader}/Properties/SRResource.Designer.cs (99%) rename src/{Microsoft.OpenApi.Readers => Microsoft.OpenApi.YamlReader}/Properties/SRResource.resx (100%) rename src/{Microsoft.OpenApi.Readers => Microsoft.OpenApi.YamlReader}/YamlConverter.cs (99%) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index ed791e58b..59f51aef5 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -136,7 +136,7 @@ extends: displayName: 'pack OpenAPI' # Pack readers - - pwsh: dotnet pack $(Build.SourcesDirectory)/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj -o $(Build.ArtifactStagingDirectory) --configuration $(BuildConfiguration) --no-build --include-symbols --include-source /p:SymbolPackageFormat=snupkg + - pwsh: dotnet pack $(Build.SourcesDirectory)/src/Microsoft.OpenApi.YamlReader/Microsoft.OpenApi.YamlReader.csproj -o $(Build.ArtifactStagingDirectory) --configuration $(BuildConfiguration) --no-build --include-symbols --include-source /p:SymbolPackageFormat=snupkg displayName: 'pack Readers' # Pack hidi @@ -239,7 +239,7 @@ extends: vmImage: ubuntu-latest steps: - powershell: | - $fileNames = "$(Pipeline.Workspace)/Microsoft.OpenApi.Hidi.*.nupkg", "$(Pipeline.Workspace)/Microsoft.OpenApi.Readers.*.nupkg", "$(Pipeline.Workspace)/Microsoft.OpenApi.Workbench.*.nupkg" + $fileNames = "$(Pipeline.Workspace)/Microsoft.OpenApi.Hidi.*.nupkg", "$(Pipeline.Workspace)/Microsoft.OpenApi.YamlReader.*.nupkg", "$(Pipeline.Workspace)/Microsoft.OpenApi.Workbench.*.nupkg" foreach($fileName in $fileNames) { if(Test-Path $fileName) { rm $fileName -Verbose @@ -273,7 +273,7 @@ extends: - task: 1ES.PublishNuget@1 displayName: 'NuGet push' inputs: - packagesToPush: '$(Pipeline.Workspace)/Microsoft.OpenApi.Readers.*.nupkg' + packagesToPush: '$(Pipeline.Workspace)/Microsoft.OpenApi.YamlReader.*.nupkg' packageParentPath: '$(Pipeline.Workspace)' nuGetFeedType: external publishFeedCredentials: 'OpenAPI Nuget Connection' diff --git a/Microsoft.OpenApi.sln b/Microsoft.OpenApi.sln index a39756a42..aa64dc5be 100644 --- a/Microsoft.OpenApi.sln +++ b/Microsoft.OpenApi.sln @@ -14,7 +14,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.OpenApi.Workbench", "src\Microsoft.OpenApi.Workbench\Microsoft.OpenApi.Workbench.csproj", "{6A5E91E5-0441-46EE-AEB9-8334981B7F08}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.OpenApi.Readers", "src\Microsoft.OpenApi.Readers\Microsoft.OpenApi.Readers.csproj", "{79933258-0126-4382-8755-D50820ECC483}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.OpenApi.YamlReader", "src\Microsoft.OpenApi.YamlReader\Microsoft.OpenApi.YamlReader.csproj", "{79933258-0126-4382-8755-D50820ECC483}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.OpenApi.Tests", "test\Microsoft.OpenApi.Tests\Microsoft.OpenApi.Tests.csproj", "{AD83F991-DBF3-4251-8613-9CC54C826964}" EndProject diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index c68a24ee0..2aa25527c 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -44,7 +44,7 @@ - + diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index c757f4031..49e905cbc 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -31,9 +31,9 @@ using Microsoft.OpenApi.Models; using Microsoft.OpenApi.OData; using Microsoft.OpenApi.Reader; -using Microsoft.OpenApi.Readers; using Microsoft.OpenApi.Services; using Microsoft.OpenApi.Writers; +using Microsoft.OpenApi.YamlReader; using static Microsoft.OpenApi.Hidi.OpenApiSpecVersionHelper; namespace Microsoft.OpenApi.Hidi diff --git a/src/Microsoft.OpenApi.Workbench/MainModel.cs b/src/Microsoft.OpenApi.Workbench/MainModel.cs index f5c0b2768..7f37c5d1b 100644 --- a/src/Microsoft.OpenApi.Workbench/MainModel.cs +++ b/src/Microsoft.OpenApi.Workbench/MainModel.cs @@ -11,9 +11,9 @@ using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Reader; -using Microsoft.OpenApi.Readers; using Microsoft.OpenApi.Services; using Microsoft.OpenApi.Validations; +using Microsoft.OpenApi.YamlReader; namespace Microsoft.OpenApi.Workbench { diff --git a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj index 03a30916e..a9b7d7eef 100644 --- a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj +++ b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj @@ -19,7 +19,7 @@ - + diff --git a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj b/src/Microsoft.OpenApi.YamlReader/Microsoft.OpenApi.YamlReader.csproj similarity index 100% rename from src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj rename to src/Microsoft.OpenApi.YamlReader/Microsoft.OpenApi.YamlReader.csproj diff --git a/src/Microsoft.OpenApi.Readers/OpenApiYamlReader.cs b/src/Microsoft.OpenApi.YamlReader/OpenApiYamlReader.cs similarity index 99% rename from src/Microsoft.OpenApi.Readers/OpenApiYamlReader.cs rename to src/Microsoft.OpenApi.YamlReader/OpenApiYamlReader.cs index eba4fd248..623b92065 100644 --- a/src/Microsoft.OpenApi.Readers/OpenApiYamlReader.cs +++ b/src/Microsoft.OpenApi.YamlReader/OpenApiYamlReader.cs @@ -14,7 +14,7 @@ using System.Linq; using System.Text; -namespace Microsoft.OpenApi.Readers +namespace Microsoft.OpenApi.YamlReader { /// /// Reader for parsing YAML files into an OpenAPI document. diff --git a/src/Microsoft.OpenApi.Readers/Properties/AssemblyInfo.cs b/src/Microsoft.OpenApi.YamlReader/Properties/AssemblyInfo.cs similarity index 100% rename from src/Microsoft.OpenApi.Readers/Properties/AssemblyInfo.cs rename to src/Microsoft.OpenApi.YamlReader/Properties/AssemblyInfo.cs diff --git a/src/Microsoft.OpenApi.Readers/Properties/SRResource.Designer.cs b/src/Microsoft.OpenApi.YamlReader/Properties/SRResource.Designer.cs similarity index 99% rename from src/Microsoft.OpenApi.Readers/Properties/SRResource.Designer.cs rename to src/Microsoft.OpenApi.YamlReader/Properties/SRResource.Designer.cs index a35dab766..595fce82e 100644 --- a/src/Microsoft.OpenApi.Readers/Properties/SRResource.Designer.cs +++ b/src/Microsoft.OpenApi.YamlReader/Properties/SRResource.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace Microsoft.OpenApi.Reader.Properties { +namespace Microsoft.OpenApi.YamlReader.Properties { using System; diff --git a/src/Microsoft.OpenApi.Readers/Properties/SRResource.resx b/src/Microsoft.OpenApi.YamlReader/Properties/SRResource.resx similarity index 100% rename from src/Microsoft.OpenApi.Readers/Properties/SRResource.resx rename to src/Microsoft.OpenApi.YamlReader/Properties/SRResource.resx diff --git a/src/Microsoft.OpenApi.Readers/YamlConverter.cs b/src/Microsoft.OpenApi.YamlReader/YamlConverter.cs similarity index 99% rename from src/Microsoft.OpenApi.Readers/YamlConverter.cs rename to src/Microsoft.OpenApi.YamlReader/YamlConverter.cs index 7d338ffa1..e2fc5f434 100644 --- a/src/Microsoft.OpenApi.Readers/YamlConverter.cs +++ b/src/Microsoft.OpenApi.YamlReader/YamlConverter.cs @@ -6,7 +6,7 @@ using SharpYaml; using SharpYaml.Serialization; -namespace Microsoft.OpenApi.Reader +namespace Microsoft.OpenApi.YamlReader { /// /// Provides extensions to convert YAML models to JSON models. diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs index b4a04c4ce..1389d3246 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs +++ b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs @@ -12,7 +12,7 @@ using Microsoft.OpenApi.Models; using Microsoft.OpenApi.OData; using Microsoft.OpenApi.Reader; -using Microsoft.OpenApi.Readers; +using Microsoft.OpenApi.YamlReader; using Microsoft.OpenApi.Services; using Xunit; 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 9b1996952..956f12421 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj +++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj @@ -26,7 +26,7 @@ - + diff --git a/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiDiagnosticTests.cs b/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiDiagnosticTests.cs index 5e065a1e8..d04c4ae58 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiDiagnosticTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiDiagnosticTests.cs @@ -9,6 +9,7 @@ using System.IO; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Reader; +using Microsoft.OpenApi.YamlReader; namespace Microsoft.OpenApi.Readers.Tests.OpenApiReaderTests { diff --git a/test/Microsoft.OpenApi.Readers.Tests/ParseNodeTests.cs b/test/Microsoft.OpenApi.Readers.Tests/ParseNodeTests.cs index e8d22a14a..855429cac 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/ParseNodeTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/ParseNodeTests.cs @@ -5,7 +5,7 @@ using Microsoft.OpenApi.Exceptions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Reader; -using Microsoft.OpenApi.Readers; +using Microsoft.OpenApi.YamlReader; using Xunit; namespace Microsoft.OpenApi.Tests diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 120e8b398..08998c30c 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -23,6 +23,7 @@ + diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs index 3716a0b32..fff156a76 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs @@ -13,8 +13,8 @@ using Microsoft.OpenApi.Models.Interfaces; using Microsoft.OpenApi.Models.References; using Microsoft.OpenApi.Reader; -using Microsoft.OpenApi.Readers; using Microsoft.OpenApi.Writers; +using Microsoft.OpenApi.YamlReader; using Microsoft.VisualBasic; using VerifyXunit; using Xunit; diff --git a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiCallbackReferenceTests.cs b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiCallbackReferenceTests.cs index 34284b9bd..99b2220cc 100644 --- a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiCallbackReferenceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiCallbackReferenceTests.cs @@ -8,8 +8,8 @@ using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.References; using Microsoft.OpenApi.Reader; -using Microsoft.OpenApi.Readers; using Microsoft.OpenApi.Writers; +using Microsoft.OpenApi.YamlReader; using VerifyXunit; using Xunit; diff --git a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiExampleReferenceTests.cs b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiExampleReferenceTests.cs index a52c027f9..fe4e0f3cc 100644 --- a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiExampleReferenceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiExampleReferenceTests.cs @@ -8,8 +8,8 @@ using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.References; using Microsoft.OpenApi.Reader; -using Microsoft.OpenApi.Readers; using Microsoft.OpenApi.Writers; +using Microsoft.OpenApi.YamlReader; using VerifyXunit; using Xunit; diff --git a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiHeaderReferenceTests.cs b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiHeaderReferenceTests.cs index 9b3c6c544..1f8afe292 100644 --- a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiHeaderReferenceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiHeaderReferenceTests.cs @@ -8,7 +8,7 @@ using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.References; using Microsoft.OpenApi.Reader; -using Microsoft.OpenApi.Readers; +using Microsoft.OpenApi.YamlReader; using Microsoft.OpenApi.Writers; using VerifyXunit; using Xunit; diff --git a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiLinkReferenceTests.cs b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiLinkReferenceTests.cs index 44822454f..19838a6e2 100644 --- a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiLinkReferenceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiLinkReferenceTests.cs @@ -8,7 +8,7 @@ using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.References; using Microsoft.OpenApi.Reader; -using Microsoft.OpenApi.Readers; +using Microsoft.OpenApi.YamlReader; using Microsoft.OpenApi.Writers; using VerifyXunit; using Xunit; diff --git a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiParameterReferenceTests.cs b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiParameterReferenceTests.cs index 8afc96f04..6ee961a32 100644 --- a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiParameterReferenceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiParameterReferenceTests.cs @@ -8,7 +8,7 @@ using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.References; using Microsoft.OpenApi.Reader; -using Microsoft.OpenApi.Readers; +using Microsoft.OpenApi.YamlReader; using Microsoft.OpenApi.Writers; using VerifyXunit; using Xunit; diff --git a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiPathItemReferenceTests.cs b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiPathItemReferenceTests.cs index 55c5bc7b5..17fa9fded 100644 --- a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiPathItemReferenceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiPathItemReferenceTests.cs @@ -8,7 +8,7 @@ using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.References; using Microsoft.OpenApi.Reader; -using Microsoft.OpenApi.Readers; +using Microsoft.OpenApi.YamlReader; using Microsoft.OpenApi.Writers; using VerifyXunit; using Xunit; diff --git a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiRequestBodyReferenceTests.cs b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiRequestBodyReferenceTests.cs index ef9bea785..66a009b0d 100644 --- a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiRequestBodyReferenceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiRequestBodyReferenceTests.cs @@ -8,7 +8,7 @@ using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.References; using Microsoft.OpenApi.Reader; -using Microsoft.OpenApi.Readers; +using Microsoft.OpenApi.YamlReader; using Microsoft.OpenApi.Writers; using VerifyXunit; using Xunit; diff --git a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiResponseReferenceTest.cs b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiResponseReferenceTest.cs index 785ea5e55..74275fea5 100644 --- a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiResponseReferenceTest.cs +++ b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiResponseReferenceTest.cs @@ -8,7 +8,7 @@ using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.References; using Microsoft.OpenApi.Reader; -using Microsoft.OpenApi.Readers; +using Microsoft.OpenApi.YamlReader; using Microsoft.OpenApi.Writers; using VerifyXunit; using Xunit; diff --git a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiSecuritySchemeReferenceTests.cs b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiSecuritySchemeReferenceTests.cs index 56b7e6d07..b8424c21f 100644 --- a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiSecuritySchemeReferenceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiSecuritySchemeReferenceTests.cs @@ -7,7 +7,7 @@ using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.References; using Microsoft.OpenApi.Reader; -using Microsoft.OpenApi.Readers; +using Microsoft.OpenApi.YamlReader; using Microsoft.OpenApi.Writers; using VerifyXunit; using Xunit; diff --git a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiTagReferenceTest.cs b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiTagReferenceTest.cs index 250f8ee53..773f5cb0f 100644 --- a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiTagReferenceTest.cs +++ b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiTagReferenceTest.cs @@ -8,7 +8,7 @@ using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.References; using Microsoft.OpenApi.Reader; -using Microsoft.OpenApi.Readers; +using Microsoft.OpenApi.YamlReader; using Microsoft.OpenApi.Writers; using VerifyXunit; using Xunit; diff --git a/test/Microsoft.OpenApi.Trimming.Tests/Microsoft.OpenApi.Trimming.Tests.csproj b/test/Microsoft.OpenApi.Trimming.Tests/Microsoft.OpenApi.Trimming.Tests.csproj index fad2dc289..f41ad23a1 100644 --- a/test/Microsoft.OpenApi.Trimming.Tests/Microsoft.OpenApi.Trimming.Tests.csproj +++ b/test/Microsoft.OpenApi.Trimming.Tests/Microsoft.OpenApi.Trimming.Tests.csproj @@ -15,7 +15,7 @@ - + From 1a689bd7c7e0aa45aee2b3c4ed56736de0ecd7dd Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Tue, 25 Feb 2025 18:23:36 +0300 Subject: [PATCH 002/984] fix: clean up project references --- .../Properties/SRResource.Designer.cs | 2 +- .../Microsoft.OpenApi.Hidi.Tests.csproj | 1 + .../Microsoft.OpenApi.Readers.Tests.csproj | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi.YamlReader/Properties/SRResource.Designer.cs b/src/Microsoft.OpenApi.YamlReader/Properties/SRResource.Designer.cs index 595fce82e..2e8a4243a 100644 --- a/src/Microsoft.OpenApi.YamlReader/Properties/SRResource.Designer.cs +++ b/src/Microsoft.OpenApi.YamlReader/Properties/SRResource.Designer.cs @@ -39,7 +39,7 @@ internal SRResource() { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.OpenApi.Readers.Properties.SRResource", typeof(SRResource).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.OpenApi.YamlReader.Properties.SRResource", typeof(SRResource).Assembly); resourceMan = temp; } return resourceMan; 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 13e98bc0e..47d67fc5b 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj +++ b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj @@ -21,6 +21,7 @@ + diff --git a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj index 956f12421..24ca03155 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj +++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj @@ -25,8 +25,8 @@ - + From adb30a10cc650e3969cccfd2d6b41ef9339e6dd0 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Tue, 25 Feb 2025 18:41:33 +0300 Subject: [PATCH 003/984] chore: fix trimmer root assembly target --- .github/workflows/codeql-analysis.yml | 2 +- .../Microsoft.OpenApi.Trimming.Tests.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 776426049..e7810ec2d 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -38,7 +38,7 @@ jobs: run: | $projectsArray = @( '.\src\Microsoft.OpenApi\Microsoft.OpenApi.csproj', - '.\src\Microsoft.OpenApi.Readers\Microsoft.OpenApi.Readers.csproj', + '.\src\Microsoft.OpenApi.YamlReader\Microsoft.OpenApi.YamlReader.csproj', '.\src\Microsoft.OpenApi.Hidi\Microsoft.OpenApi.Hidi.csproj' ) diff --git a/test/Microsoft.OpenApi.Trimming.Tests/Microsoft.OpenApi.Trimming.Tests.csproj b/test/Microsoft.OpenApi.Trimming.Tests/Microsoft.OpenApi.Trimming.Tests.csproj index f41ad23a1..20d8d8d70 100644 --- a/test/Microsoft.OpenApi.Trimming.Tests/Microsoft.OpenApi.Trimming.Tests.csproj +++ b/test/Microsoft.OpenApi.Trimming.Tests/Microsoft.OpenApi.Trimming.Tests.csproj @@ -16,7 +16,7 @@ - + From f407815a2b89599329facf3e525f7c2014e96560 Mon Sep 17 00:00:00 2001 From: Safia Abdalla Date: Fri, 7 Mar 2025 21:58:57 -0800 Subject: [PATCH 004/984] Fix handling for reference IDs with http prefix --- build.sh | 22 ++++++++++++++++ global.json | 5 ++++ .../Models/OpenApiReference.cs | 6 +++-- .../Models/OpenApiReferenceTests.cs | 26 +++++++++++++++++++ 4 files changed, 57 insertions(+), 2 deletions(-) create mode 100755 build.sh create mode 100644 global.json diff --git a/build.sh b/build.sh new file mode 100755 index 000000000..e716aa272 --- /dev/null +++ b/build.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +echo "Building Microsoft.OpenApi" + +PROJ="$(dirname "$0")/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj" +dotnet msbuild "$PROJ" /t:restore /p:Configuration=Release +dotnet msbuild "$PROJ" /t:build /p:Configuration=Release +dotnet msbuild "$PROJ" /t:pack "/p:Configuration=Release;PackageOutputPath=$(dirname "$0")/artifacts" + +echo "Building Microsoft.OpenApi.Readers" + +PROJ="$(dirname "$0")/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj" +dotnet msbuild "$PROJ" /t:restore /p:Configuration=Release +dotnet msbuild "$PROJ" /t:build /p:Configuration=Release +dotnet msbuild "$PROJ" /t:pack "/p:Configuration=Release;PackageOutputPath=$(dirname "$0")/artifacts" + +echo "Building Microsoft.OpenApi.Hidi" + +PROJ="$(dirname "$0")/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj" +dotnet msbuild "$PROJ" /t:restore /p:Configuration=Release +dotnet msbuild "$PROJ" /t:build /p:Configuration=Release +dotnet msbuild "$PROJ" /t:pack "/p:Configuration=Release;PackageOutputPath=$(dirname "$0")/artifacts" \ No newline at end of file diff --git a/global.json b/global.json new file mode 100644 index 000000000..aea4e9e3a --- /dev/null +++ b/global.json @@ -0,0 +1,5 @@ +{ + "sdk": { + "version": "8.0.406" + } +} \ No newline at end of file diff --git a/src/Microsoft.OpenApi/Models/OpenApiReference.cs b/src/Microsoft.OpenApi/Models/OpenApiReference.cs index 43d307fad..3ada601c0 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiReference.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiReference.cs @@ -97,7 +97,8 @@ public string ReferenceV3 { return Id; } - if (Id.StartsWith("http", StringComparison.OrdinalIgnoreCase)) + if (Id.StartsWith("http://", StringComparison.OrdinalIgnoreCase) || + Id.StartsWith("https://", StringComparison.OrdinalIgnoreCase)) { return Id; } @@ -241,7 +242,8 @@ private string GetExternalReferenceV3() return ExternalResource + "#" + Id; } - if (Id.StartsWith("http", StringComparison.OrdinalIgnoreCase)) + if (Id.StartsWith("http://", StringComparison.OrdinalIgnoreCase) || + Id.StartsWith("https://", StringComparison.OrdinalIgnoreCase)) { return Id; } diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiReferenceTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiReferenceTests.cs index 2a27313ca..b75cb89e4 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiReferenceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiReferenceTests.cs @@ -15,6 +15,7 @@ public class OpenApiReferenceTests [InlineData("#/components/schemas/Pet", ReferenceType.Schema, "Pet")] [InlineData("#/components/parameters/name", ReferenceType.Parameter, "name")] [InlineData("#/components/responses/200", ReferenceType.Response, "200")] + [InlineData("#/components/schemas/HttpValidationsProblem", ReferenceType.Schema, "HttpValidationsProblem")] public void SettingInternalReferenceForComponentsStyleReferenceShouldSucceed( string input, ReferenceType type, @@ -43,6 +44,7 @@ public void SettingInternalReferenceForComponentsStyleReferenceShouldSucceed( [InlineData("Pet.json#/components/schemas/Pet", "Pet.json", "Pet", ReferenceType.Schema)] [InlineData("Pet.yaml#/components/schemas/Pet", "Pet.yaml", "Pet", ReferenceType.Schema)] [InlineData("abc#/components/schemas/Pet", "abc", "Pet", ReferenceType.Schema)] + [InlineData("abc#/components/schemas/HttpsValidationProblem", "abc", "HttpsValidationProblem", ReferenceType.Schema)] public void SettingExternalReferenceV3ShouldSucceed(string expected, string externalResource, string id, ReferenceType? type) { // Arrange & Act @@ -105,6 +107,30 @@ public async Task SerializeSchemaReferenceAsJsonV3Works() Assert.Equal(expected, actual); } + [Theory] + [InlineData("HttpValidationProblemDetails", "#/components/schemas/HttpValidationProblemDetails")] + [InlineData("http://example.com", "http://example.com")] + [InlineData("https://example.com", "https://example.com")] + public async Task SerializeHttpSchemaReferenceAsJsonV31Works(string id, string referenceV3) + { + // Arrange + var reference = new OpenApiReference { Type = ReferenceType.Schema, Id = id }; + var expected = + $$""" + { + "$ref": "{{referenceV3}}" + } + """; + + // Act + var actual = await reference.SerializeAsJsonAsync(OpenApiSpecVersion.OpenApi3_1); + expected = expected.MakeLineBreaksEnvironmentNeutral(); + actual = actual.MakeLineBreaksEnvironmentNeutral(); + + // Assert + Assert.Equal(expected, actual); + } + [Fact] public async Task SerializeSchemaReferenceAsYamlV3Works() { From c71b5de31da65a3298117d397b33a8785e461f9c Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Mon, 10 Mar 2025 17:05:42 +0300 Subject: [PATCH 005/984] refactor: rename annotations to metadata --- ...piAnnotatable.cs => IMetadataContainer.cs} | 6 ++--- .../Models/OpenApiDocument.cs | 6 ++--- .../Models/OpenApiOperation.cs | 6 ++--- .../Models/OpenApiDocumentTests.cs | 22 +++++++++---------- .../Models/OpenApiOperationTests.cs | 10 ++++----- .../PublicApi/PublicApi.approved.txt | 12 +++++----- 6 files changed, 31 insertions(+), 31 deletions(-) rename src/Microsoft.OpenApi/Interfaces/{IOpenApiAnnotatable.cs => IMetadataContainer.cs} (71%) diff --git a/src/Microsoft.OpenApi/Interfaces/IOpenApiAnnotatable.cs b/src/Microsoft.OpenApi/Interfaces/IMetadataContainer.cs similarity index 71% rename from src/Microsoft.OpenApi/Interfaces/IOpenApiAnnotatable.cs rename to src/Microsoft.OpenApi/Interfaces/IMetadataContainer.cs index dc1ee84a0..2d8f26220 100644 --- a/src/Microsoft.OpenApi/Interfaces/IOpenApiAnnotatable.cs +++ b/src/Microsoft.OpenApi/Interfaces/IMetadataContainer.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System.Collections.Generic; @@ -9,11 +9,11 @@ namespace Microsoft.OpenApi.Interfaces /// Represents an Open API element that can be annotated with /// non-serializable properties in a property bag. /// - public interface IOpenApiAnnotatable + public interface IMetadataContainer { /// /// A collection of properties associated with the current OpenAPI element. /// - IDictionary Annotations { get; set; } + IDictionary Metadata { get; set; } } } diff --git a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs index dd85770f3..8d04814cd 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs @@ -24,7 +24,7 @@ namespace Microsoft.OpenApi.Models /// /// Describes an OpenAPI object (OpenAPI document). See: https://spec.openapis.org /// - public class OpenApiDocument : IOpenApiSerializable, IOpenApiExtensible, IOpenApiAnnotatable + public class OpenApiDocument : IOpenApiSerializable, IOpenApiExtensible, IMetadataContainer { /// /// Register components in the document to the workspace @@ -109,7 +109,7 @@ public ISet? Tags public IDictionary? Extensions { get; set; } = new Dictionary(); /// - public IDictionary? Annotations { get; set; } + public IDictionary? Metadata { get; set; } /// /// Implements IBaseDocument @@ -143,7 +143,7 @@ public OpenApiDocument(OpenApiDocument? document) Tags = document?.Tags != null ? new HashSet(document.Tags, OpenApiTagComparer.Instance) : null; ExternalDocs = document?.ExternalDocs != null ? new(document?.ExternalDocs) : null; Extensions = document?.Extensions != null ? new Dictionary(document.Extensions) : null; - Annotations = document?.Annotations != null ? new Dictionary(document.Annotations) : null; + Metadata = document?.Metadata != null ? new Dictionary(document.Metadata) : null; BaseUri = document?.BaseUri != null ? document.BaseUri : new(OpenApiConstants.BaseRegistryUri + Guid.NewGuid()); } diff --git a/src/Microsoft.OpenApi/Models/OpenApiOperation.cs b/src/Microsoft.OpenApi/Models/OpenApiOperation.cs index 1e10f640c..2ea920640 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiOperation.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiOperation.cs @@ -16,7 +16,7 @@ namespace Microsoft.OpenApi.Models /// /// Operation Object. /// - public class OpenApiOperation : IOpenApiSerializable, IOpenApiExtensible, IOpenApiAnnotatable + public class OpenApiOperation : IOpenApiSerializable, IOpenApiExtensible, IMetadataContainer { /// /// Default value for . @@ -127,7 +127,7 @@ public ISet? Tags public IDictionary? Extensions { get; set; } = new Dictionary(); /// - public IDictionary? Annotations { get; set; } + public IDictionary? Metadata { get; set; } /// /// Parameterless constructor @@ -153,7 +153,7 @@ public OpenApiOperation(OpenApiOperation operation) Security = operation.Security != null ? new List(operation.Security) : null; Servers = operation.Servers != null ? new List(operation.Servers) : null; Extensions = operation.Extensions != null ? new Dictionary(operation.Extensions) : null; - Annotations = operation.Annotations != null ? new Dictionary(operation.Annotations) : null; + Metadata = operation.Metadata != null ? new Dictionary(operation.Metadata) : null; } /// diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs index 6c27b87ab..b286839ac 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs @@ -92,7 +92,7 @@ public class OpenApiDocumentTests { Version = "1.0.0" }, - Annotations = new Dictionary { { "key1", "value" } }, + Metadata = new Dictionary { { "key1", "value" } }, Components = TopLevelReferencingComponents }; @@ -102,7 +102,7 @@ public class OpenApiDocumentTests { Version = "1.0.0" }, - Annotations = new Dictionary { { "key1", "value" } }, + Metadata = new Dictionary { { "key1", "value" } }, Components = TopLevelSelfReferencingComponentsWithOtherProperties }; @@ -112,7 +112,7 @@ public class OpenApiDocumentTests { Version = "1.0.0" }, - Annotations = new Dictionary { { "key1", "value" } }, + Metadata = new Dictionary { { "key1", "value" } }, Components = TopLevelSelfReferencingComponents }; @@ -489,7 +489,7 @@ public class OpenApiDocumentTests } } }, - Annotations = new Dictionary { { "key1", "value" } }, + Metadata = new Dictionary { { "key1", "value" } }, Components = AdvancedComponentsWithReference }; @@ -865,7 +865,7 @@ public class OpenApiDocumentTests } } }, - Annotations = new Dictionary { { "key1", "value" } }, + Metadata = new Dictionary { { "key1", "value" } }, Components = AdvancedComponents }; @@ -1024,7 +1024,7 @@ public class OpenApiDocumentTests } } }, - Annotations = new Dictionary { { "key1", "value" } }, + Metadata = new Dictionary { { "key1", "value" } }, Components = AdvancedComponents }; @@ -1324,7 +1324,7 @@ public class OpenApiDocumentTests } } }, - Annotations = new Dictionary { { "key1", "value" } }, + Metadata = new Dictionary { { "key1", "value" } }, Components = AdvancedComponents }; @@ -1830,7 +1830,7 @@ public void OpenApiDocumentCopyConstructorWithAnnotationsSucceeds() { var baseDocument = new OpenApiDocument { - Annotations = new Dictionary + Metadata = new Dictionary { ["key1"] = "value1", ["key2"] = 2 @@ -1839,11 +1839,11 @@ public void OpenApiDocumentCopyConstructorWithAnnotationsSucceeds() var actualDocument = new OpenApiDocument(baseDocument); - Assert.Equal(baseDocument.Annotations["key1"], actualDocument.Annotations["key1"]); + Assert.Equal(baseDocument.Metadata["key1"], actualDocument.Metadata["key1"]); - baseDocument.Annotations["key1"] = "value2"; + baseDocument.Metadata["key1"] = "value2"; - Assert.NotEqual(baseDocument.Annotations["key1"], actualDocument.Annotations["key1"]); + Assert.NotEqual(baseDocument.Metadata["key1"], actualDocument.Metadata["key1"]); } [Fact] diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs index bb615f2dd..33730484b 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs @@ -84,7 +84,7 @@ public class OpenApiOperationTests Description = "serverDescription" } }, - Annotations = new Dictionary { { "key1", "value1" }, { "key2", 2 } }, + Metadata = new Dictionary { { "key1", "value1" }, { "key2", 2 } }, }; private static OpenApiOperation _advancedOperationWithTagsAndSecurity => new() @@ -844,7 +844,7 @@ public void OpenApiOperationCopyConstructorWithAnnotationsSucceeds() { var baseOperation = new OpenApiOperation { - Annotations = new Dictionary + Metadata = new Dictionary { ["key1"] = "value1", ["key2"] = 2 @@ -853,11 +853,11 @@ public void OpenApiOperationCopyConstructorWithAnnotationsSucceeds() var actualOperation = new OpenApiOperation(baseOperation); - Assert.Equal(baseOperation.Annotations["key1"], actualOperation.Annotations["key1"]); + Assert.Equal(baseOperation.Metadata["key1"], actualOperation.Metadata["key1"]); - baseOperation.Annotations["key1"] = "value2"; + baseOperation.Metadata["key1"] = "value2"; - Assert.NotEqual(baseOperation.Annotations["key1"], actualOperation.Annotations["key1"]); + Assert.NotEqual(baseOperation.Metadata["key1"], actualOperation.Metadata["key1"]); } } } diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index 0f0412510..a143a049d 100644 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -199,9 +199,9 @@ namespace Microsoft.OpenApi.Extensions namespace Microsoft.OpenApi.Interfaces { public interface IDiagnostic { } - public interface IOpenApiAnnotatable + public interface IMetadataContainer { - System.Collections.Generic.IDictionary Annotations { get; set; } + System.Collections.Generic.IDictionary Metadata { get; set; } } public interface IOpenApiElement { } public interface IOpenApiExtensible : Microsoft.OpenApi.Interfaces.IOpenApiElement @@ -706,17 +706,17 @@ namespace Microsoft.OpenApi.Models public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } } - public class OpenApiDocument : Microsoft.OpenApi.Interfaces.IOpenApiAnnotatable, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable + public class OpenApiDocument : Microsoft.OpenApi.Interfaces.IMetadataContainer, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { public OpenApiDocument() { } public OpenApiDocument(Microsoft.OpenApi.Models.OpenApiDocument? document) { } - public System.Collections.Generic.IDictionary? Annotations { get; set; } public System.Uri BaseUri { get; } public Microsoft.OpenApi.Models.OpenApiComponents? Components { get; set; } public System.Collections.Generic.IDictionary? Extensions { get; set; } public Microsoft.OpenApi.Models.OpenApiExternalDocs? ExternalDocs { get; set; } public Microsoft.OpenApi.Models.OpenApiInfo Info { get; set; } public System.Uri? JsonSchemaDialect { get; set; } + public System.Collections.Generic.IDictionary? Metadata { get; set; } public Microsoft.OpenApi.Models.OpenApiPaths Paths { get; set; } public System.Collections.Generic.IList? Security { get; set; } public System.Collections.Generic.IList? Servers { get; set; } @@ -894,17 +894,17 @@ namespace Microsoft.OpenApi.Models public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } } - public class OpenApiOperation : Microsoft.OpenApi.Interfaces.IOpenApiAnnotatable, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable + public class OpenApiOperation : Microsoft.OpenApi.Interfaces.IMetadataContainer, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { public const bool DeprecatedDefault = false; public OpenApiOperation() { } public OpenApiOperation(Microsoft.OpenApi.Models.OpenApiOperation operation) { } - public System.Collections.Generic.IDictionary? Annotations { get; set; } public System.Collections.Generic.IDictionary? Callbacks { get; set; } public bool Deprecated { get; set; } public string? Description { get; set; } public System.Collections.Generic.IDictionary? Extensions { get; set; } public Microsoft.OpenApi.Models.OpenApiExternalDocs? ExternalDocs { get; set; } + public System.Collections.Generic.IDictionary? Metadata { get; set; } public string? OperationId { get; set; } public System.Collections.Generic.IList? Parameters { get; set; } public Microsoft.OpenApi.Models.Interfaces.IOpenApiRequestBody? RequestBody { get; set; } From ca7ccdd933b57c2775d0295e22e541c2904b5fb7 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Mon, 10 Mar 2025 15:51:39 -0400 Subject: [PATCH 006/984] fix: a bug where references would not serialize summary or descriptions in 3.1 Signed-off-by: Vincent Biret --- .../Models/References/OpenApiSchemaReference.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi/Models/References/OpenApiSchemaReference.cs b/src/Microsoft.OpenApi/Models/References/OpenApiSchemaReference.cs index 919751237..8a5a84d93 100644 --- a/src/Microsoft.OpenApi/Models/References/OpenApiSchemaReference.cs +++ b/src/Microsoft.OpenApi/Models/References/OpenApiSchemaReference.cs @@ -156,7 +156,7 @@ public string Description /// public override void SerializeAsV31(IOpenApiWriter writer) { - SerializeAsWithoutLoops(writer, (w, element) => (element is IOpenApiSchema s ? CopyReferenceAsTargetElementWithOverrides(s) : element).SerializeAsV3(w)); + SerializeAsWithoutLoops(writer, (w, element) => (element is IOpenApiSchema s ? CopyReferenceAsTargetElementWithOverrides(s) : element).SerializeAsV31(w)); } /// From eeffba9d50a53a3be1630d01edd8d0b57a966dee Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Mon, 10 Mar 2025 15:52:56 -0400 Subject: [PATCH 007/984] feat: enables references as components Signed-off-by: Vincent Biret --- .../Interfaces/IOpenApiReferenceHolder.cs | 6 +- .../Models/Interfaces/IOpenApiCallback.cs | 2 +- .../Models/Interfaces/IOpenApiExample.cs | 2 +- .../Models/Interfaces/IOpenApiHeader.cs | 2 +- .../Models/Interfaces/IOpenApiLink.cs | 2 +- .../Models/Interfaces/IOpenApiParameter.cs | 2 +- .../Models/Interfaces/IOpenApiPathItem.cs | 2 +- .../Models/Interfaces/IOpenApiRequestBody.cs | 2 +- .../Models/Interfaces/IOpenApiResponse.cs | 2 +- .../Models/Interfaces/IOpenApiSchema.cs | 2 +- .../Interfaces/IOpenApiSecurityScheme.cs | 2 +- .../Models/Interfaces/IOpenApiTag.cs | 2 +- .../Models/OpenApiDocument.cs | 12 +- src/Microsoft.OpenApi/Models/OpenApiHeader.cs | 2 +- .../Models/OpenApiParameter.cs | 2 +- .../Models/OpenApiReference.cs | 22 +++ src/Microsoft.OpenApi/Models/OpenApiSchema.cs | 2 +- .../References/BaseOpenApiReferenceHolder.cs | 21 ++- .../Models/References/OpenApiTagReference.cs | 2 +- .../Reader/V31/OpenApiSchemaDeserializer.cs | 4 +- .../Services/CopyReferences.cs | 20 +-- .../V3Tests/OpenApiDocumentTests.cs | 151 ++++++++++++++++++ .../PublicApi/PublicApi.approved.txt | 54 ++++--- 23 files changed, 256 insertions(+), 64 deletions(-) diff --git a/src/Microsoft.OpenApi/Interfaces/IOpenApiReferenceHolder.cs b/src/Microsoft.OpenApi/Interfaces/IOpenApiReferenceHolder.cs index 8883a90f5..6c3b0df57 100644 --- a/src/Microsoft.OpenApi/Interfaces/IOpenApiReferenceHolder.cs +++ b/src/Microsoft.OpenApi/Interfaces/IOpenApiReferenceHolder.cs @@ -15,7 +15,11 @@ public interface IOpenApiReferenceHolder : IOpenApiReferenceHolder whe /// /// Gets the resolved target object. /// - T Target { get; } + V Target { get; } + /// + /// Gets the recursively resolved target object. + /// + T RecursiveTarget { get; } /// /// Copy the reference as a target element with overrides. /// diff --git a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiCallback.cs b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiCallback.cs index a8a818d33..025abca20 100644 --- a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiCallback.cs +++ b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiCallback.cs @@ -9,7 +9,7 @@ namespace Microsoft.OpenApi.Models.Interfaces; /// Defines the base properties for the callback object. /// This interface is provided for type assertions but should not be implemented by package consumers beyond automatic mocking. /// -public interface IOpenApiCallback : IOpenApiSerializable, IOpenApiReadOnlyExtensible, IShallowCopyable +public interface IOpenApiCallback : IOpenApiReadOnlyExtensible, IShallowCopyable, IOpenApiReferenceable { /// /// A Path Item Object used to define a callback request and expected responses. diff --git a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiExample.cs b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiExample.cs index ece8b48ad..9a14aca95 100644 --- a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiExample.cs +++ b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiExample.cs @@ -7,7 +7,7 @@ namespace Microsoft.OpenApi.Models.Interfaces; /// Defines the base properties for the example object. /// This interface is provided for type assertions but should not be implemented by package consumers beyond automatic mocking. /// -public interface IOpenApiExample : IOpenApiDescribedElement, IOpenApiSummarizedElement, IOpenApiSerializable, IOpenApiReadOnlyExtensible, IShallowCopyable +public interface IOpenApiExample : IOpenApiDescribedElement, IOpenApiSummarizedElement, IOpenApiReadOnlyExtensible, IShallowCopyable, IOpenApiReferenceable { /// /// Embedded literal example. The value field and externalValue field are mutually diff --git a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiHeader.cs b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiHeader.cs index 35b6cdfe9..69d7ec614 100644 --- a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiHeader.cs +++ b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiHeader.cs @@ -9,7 +9,7 @@ namespace Microsoft.OpenApi.Models.Interfaces; /// Defines the base properties for the headers object. /// This interface is provided for type assertions but should not be implemented by package consumers beyond automatic mocking. /// -public interface IOpenApiHeader : IOpenApiDescribedElement, IOpenApiSerializable, IOpenApiReadOnlyExtensible, IShallowCopyable +public interface IOpenApiHeader : IOpenApiDescribedElement, IOpenApiReadOnlyExtensible, IShallowCopyable, IOpenApiReferenceable { /// /// Determines whether this header is mandatory. diff --git a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiLink.cs b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiLink.cs index 66e8b5e3b..f6ee7b49d 100644 --- a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiLink.cs +++ b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiLink.cs @@ -7,7 +7,7 @@ namespace Microsoft.OpenApi.Models.Interfaces; /// Defines the base properties for the link object. /// This interface is provided for type assertions but should not be implemented by package consumers beyond automatic mocking. /// -public interface IOpenApiLink : IOpenApiDescribedElement, IOpenApiSerializable, IOpenApiReadOnlyExtensible, IShallowCopyable +public interface IOpenApiLink : IOpenApiDescribedElement, IOpenApiReadOnlyExtensible, IShallowCopyable, IOpenApiReferenceable { /// /// A relative or absolute reference to an OAS operation. diff --git a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiParameter.cs b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiParameter.cs index 465078e43..a55ce742b 100644 --- a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiParameter.cs +++ b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiParameter.cs @@ -8,7 +8,7 @@ namespace Microsoft.OpenApi.Models.Interfaces; /// Defines the base properties for the parameter object. /// This interface is provided for type assertions but should not be implemented by package consumers beyond automatic mocking. /// -public interface IOpenApiParameter : IOpenApiDescribedElement, IOpenApiSerializable, IOpenApiReadOnlyExtensible, IShallowCopyable +public interface IOpenApiParameter : IOpenApiDescribedElement, IOpenApiReadOnlyExtensible, IShallowCopyable, IOpenApiReferenceable { /// /// REQUIRED. The name of the parameter. Parameter names are case sensitive. diff --git a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiPathItem.cs b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiPathItem.cs index bbc316a14..fe0d5bdef 100644 --- a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiPathItem.cs +++ b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiPathItem.cs @@ -8,7 +8,7 @@ namespace Microsoft.OpenApi.Models.Interfaces; /// Defines the base properties for the path item object. /// This interface is provided for type assertions but should not be implemented by package consumers beyond automatic mocking. /// -public interface IOpenApiPathItem : IOpenApiDescribedElement, IOpenApiSummarizedElement, IOpenApiSerializable, IOpenApiReadOnlyExtensible, IShallowCopyable +public interface IOpenApiPathItem : IOpenApiDescribedElement, IOpenApiSummarizedElement, IOpenApiReadOnlyExtensible, IShallowCopyable, IOpenApiReferenceable { /// /// Gets the definition of operations on this path. diff --git a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiRequestBody.cs b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiRequestBody.cs index 84afff156..b03bac603 100644 --- a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiRequestBody.cs +++ b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiRequestBody.cs @@ -8,7 +8,7 @@ namespace Microsoft.OpenApi.Models.Interfaces; /// Defines the base properties for the request body object. /// This interface is provided for type assertions but should not be implemented by package consumers beyond automatic mocking. /// -public interface IOpenApiRequestBody : IOpenApiDescribedElement, IOpenApiSerializable, IOpenApiReadOnlyExtensible, IShallowCopyable +public interface IOpenApiRequestBody : IOpenApiDescribedElement, IOpenApiReadOnlyExtensible, IShallowCopyable, IOpenApiReferenceable { /// /// Determines if the request body is required in the request. Defaults to false. diff --git a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiResponse.cs b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiResponse.cs index 3df66eec0..ee4e6df10 100644 --- a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiResponse.cs +++ b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiResponse.cs @@ -7,7 +7,7 @@ namespace Microsoft.OpenApi.Models.Interfaces; /// Defines the base properties for the response object. /// This interface is provided for type assertions but should not be implemented by package consumers beyond automatic mocking. /// -public interface IOpenApiResponse : IOpenApiDescribedElement, IOpenApiSerializable, IOpenApiReadOnlyExtensible, IShallowCopyable +public interface IOpenApiResponse : IOpenApiDescribedElement, IOpenApiReadOnlyExtensible, IShallowCopyable, IOpenApiReferenceable { /// /// Maps a header name to its definition. diff --git a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiSchema.cs b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiSchema.cs index 6afae8fd6..b6352311c 100644 --- a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiSchema.cs +++ b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiSchema.cs @@ -9,7 +9,7 @@ namespace Microsoft.OpenApi.Models.Interfaces; /// Defines the base properties for the schema object. /// This interface is provided for type assertions but should not be implemented by package consumers beyond automatic mocking. /// -public interface IOpenApiSchema : IOpenApiDescribedElement, IOpenApiSerializable, IOpenApiReadOnlyExtensible, IShallowCopyable +public interface IOpenApiSchema : IOpenApiDescribedElement, IOpenApiReadOnlyExtensible, IShallowCopyable, IOpenApiReferenceable { /// diff --git a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiSecurityScheme.cs b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiSecurityScheme.cs index 9580a3dad..d076a6896 100644 --- a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiSecurityScheme.cs +++ b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiSecurityScheme.cs @@ -8,7 +8,7 @@ namespace Microsoft.OpenApi.Models.Interfaces; /// Defines the base properties for the security scheme object. /// This interface is provided for type assertions but should not be implemented by package consumers beyond automatic mocking. /// -public interface IOpenApiSecurityScheme : IOpenApiDescribedElement, IOpenApiSerializable, IOpenApiReadOnlyExtensible, IShallowCopyable +public interface IOpenApiSecurityScheme : IOpenApiDescribedElement, IOpenApiReadOnlyExtensible, IShallowCopyable, IOpenApiReferenceable { /// /// REQUIRED. The type of the security scheme. Valid values are "apiKey", "http", "oauth2", "openIdConnect". diff --git a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiTag.cs b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiTag.cs index c2a6d8523..fdf022413 100644 --- a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiTag.cs +++ b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiTag.cs @@ -6,7 +6,7 @@ namespace Microsoft.OpenApi.Models.Interfaces; /// Defines the base properties for the path item object. /// This interface is provided for type assertions but should not be implemented by package consumers beyond automatic mocking. /// -public interface IOpenApiTag : IOpenApiSerializable, IOpenApiReadOnlyExtensible, IOpenApiReadOnlyDescribedElement, IShallowCopyable +public interface IOpenApiTag : IOpenApiReadOnlyExtensible, IOpenApiReadOnlyDescribedElement, IShallowCopyable, IOpenApiReferenceable { /// /// The name of the tag. diff --git a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs index 8d04814cd..164b3330b 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs @@ -463,16 +463,14 @@ public void SetReferenceHostDocument() /// /// Load the referenced object from a object /// - internal T? ResolveReferenceTo(OpenApiReference reference) where T : class, IOpenApiReferenceable + internal T? ResolveReferenceTo(OpenApiReference reference) where T : IOpenApiReferenceable { - if (reference.IsExternal) - { - return ResolveReference(reference, true) as T; - } - else + + if (ResolveReference(reference, reference.IsExternal) is T result) { - return ResolveReference(reference, false) as T; + return result; } + return default; } /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiHeader.cs b/src/Microsoft.OpenApi/Models/OpenApiHeader.cs index dd7a0ec84..971d88c94 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiHeader.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiHeader.cs @@ -174,7 +174,7 @@ public void SerializeAsV2(IOpenApiWriter writer) // schema var targetSchema = Schema switch { - OpenApiSchemaReference schemaReference => schemaReference.Target, + OpenApiSchemaReference schemaReference => schemaReference.RecursiveTarget, OpenApiSchema schema => schema, _ => null, }; diff --git a/src/Microsoft.OpenApi/Models/OpenApiParameter.cs b/src/Microsoft.OpenApi/Models/OpenApiParameter.cs index 0f1d7c03a..40dc918fb 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiParameter.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiParameter.cs @@ -232,7 +232,7 @@ public void SerializeAsV2(IOpenApiWriter writer) // enum // multipleOf var targetSchema = Schema switch { - OpenApiSchemaReference schemaReference => schemaReference.Target, + OpenApiSchemaReference schemaReference => schemaReference.RecursiveTarget, OpenApiSchema schema => schema, _ => null, }; diff --git a/src/Microsoft.OpenApi/Models/OpenApiReference.cs b/src/Microsoft.OpenApi/Models/OpenApiReference.cs index 3ada601c0..00d992a9e 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiReference.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiReference.cs @@ -2,9 +2,11 @@ // Licensed under the MIT license. using System; +using System.Text.Json.Nodes; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models.Interfaces; +using Microsoft.OpenApi.Reader.ParseNodes; using Microsoft.OpenApi.Writers; namespace Microsoft.OpenApi.Models @@ -292,5 +294,25 @@ internal void EnsureHostDocumentIsSet(OpenApiDocument currentDocument) Utils.CheckArgumentNull(currentDocument); hostDocument ??= currentDocument; } + #nullable enable + private static string? GetPropertyValueFromNode(JsonObject jsonObject, string key) => + jsonObject.TryGetPropertyValue(key, out var valueNode) && valueNode is JsonValue valueCast && valueCast.TryGetValue(out var strValue) ? strValue : null; + #nullable restore + internal void SetSummaryAndDescriptionFromMapNode(MapNode mapNode) + { + var (description, summary) = mapNode.JsonNode switch { + JsonObject jsonObject => (GetPropertyValueFromNode(jsonObject, OpenApiConstants.Description), + GetPropertyValueFromNode(jsonObject, OpenApiConstants.Summary)), + _ => (null, null) + }; + if (!string.IsNullOrEmpty(description)) + { + Description = description; + } + if (!string.IsNullOrEmpty(summary)) + { + Summary = summary; + } + } } } diff --git a/src/Microsoft.OpenApi/Models/OpenApiSchema.cs b/src/Microsoft.OpenApi/Models/OpenApiSchema.cs index 44bb2078b..10f403efc 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiSchema.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiSchema.cs @@ -18,7 +18,7 @@ namespace Microsoft.OpenApi.Models /// /// The Schema Object allows the definition of input and output data types. /// - public class OpenApiSchema : IOpenApiReferenceable, IOpenApiExtensible, IOpenApiSchema + public class OpenApiSchema : IOpenApiExtensible, IOpenApiSchema { /// public string Title { get; set; } diff --git a/src/Microsoft.OpenApi/Models/References/BaseOpenApiReferenceHolder.cs b/src/Microsoft.OpenApi/Models/References/BaseOpenApiReferenceHolder.cs index 2f402b8cc..ea1839f49 100644 --- a/src/Microsoft.OpenApi/Models/References/BaseOpenApiReferenceHolder.cs +++ b/src/Microsoft.OpenApi/Models/References/BaseOpenApiReferenceHolder.cs @@ -1,4 +1,4 @@ -using System; +using System; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Writers; @@ -8,14 +8,27 @@ namespace Microsoft.OpenApi.Models.References; /// /// The concrete class implementation type for the model. /// The interface type for the model. -public abstract class BaseOpenApiReferenceHolder : IOpenApiReferenceHolder where T : class, IOpenApiReferenceable, V where V : IOpenApiSerializable +public abstract class BaseOpenApiReferenceHolder : IOpenApiReferenceHolder where T : class, IOpenApiReferenceable, V where V : IOpenApiReferenceable, IOpenApiSerializable { /// - public virtual T Target + public virtual V Target { get { - return Reference.HostDocument?.ResolveReferenceTo(Reference); + if (Reference.HostDocument is null) return default; + return Reference.HostDocument.ResolveReferenceTo(Reference); + } + } + /// + public T RecursiveTarget + { + get + { + return Target switch { + BaseOpenApiReferenceHolder recursiveTarget => recursiveTarget.RecursiveTarget, + T concrete => concrete, + _ => null + }; } } /// diff --git a/src/Microsoft.OpenApi/Models/References/OpenApiTagReference.cs b/src/Microsoft.OpenApi/Models/References/OpenApiTagReference.cs index 019d4c367..031b5dbb1 100644 --- a/src/Microsoft.OpenApi/Models/References/OpenApiTagReference.cs +++ b/src/Microsoft.OpenApi/Models/References/OpenApiTagReference.cs @@ -17,7 +17,7 @@ public class OpenApiTagReference : BaseOpenApiReferenceHolder /// Resolved target of the reference. /// - public override OpenApiTag Target + public override IOpenApiTag Target { get { diff --git a/src/Microsoft.OpenApi/Reader/V31/OpenApiSchemaDeserializer.cs b/src/Microsoft.OpenApi/Reader/V31/OpenApiSchemaDeserializer.cs index 7f16c3af0..4be2a4b5d 100644 --- a/src/Microsoft.OpenApi/Reader/V31/OpenApiSchemaDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V31/OpenApiSchemaDeserializer.cs @@ -257,7 +257,9 @@ public static IOpenApiSchema LoadSchema(ParseNode node, OpenApiDocument hostDocu if (pointer != null) { var reference = GetReferenceIdAndExternalResource(pointer); - return new OpenApiSchemaReference(reference.Item1, hostDocument, reference.Item2); + var result = new OpenApiSchemaReference(reference.Item1, hostDocument, reference.Item2); + result.Reference.SetSummaryAndDescriptionFromMapNode(mapNode); + return result; } var schema = new OpenApiSchema(); diff --git a/src/Microsoft.OpenApi/Services/CopyReferences.cs b/src/Microsoft.OpenApi/Services/CopyReferences.cs index 980aafb56..ab0ad8e31 100644 --- a/src/Microsoft.OpenApi/Services/CopyReferences.cs +++ b/src/Microsoft.OpenApi/Services/CopyReferences.cs @@ -85,7 +85,7 @@ public override void Visit(IOpenApiReferenceHolder referenceHolder) base.Visit(referenceHolder); } - private void AddSchemaToComponents(OpenApiSchema schema, string referenceId = null) + private void AddSchemaToComponents(IOpenApiSchema schema, string referenceId = null) { EnsureComponentsExist(); EnsureSchemasExist(); @@ -95,7 +95,7 @@ private void AddSchemaToComponents(OpenApiSchema schema, string referenceId = nu } } - private void AddParameterToComponents(OpenApiParameter parameter, string referenceId = null) + private void AddParameterToComponents(IOpenApiParameter parameter, string referenceId = null) { EnsureComponentsExist(); EnsureParametersExist(); @@ -105,7 +105,7 @@ private void AddParameterToComponents(OpenApiParameter parameter, string referen } } - private void AddResponseToComponents(OpenApiResponse response, string referenceId = null) + private void AddResponseToComponents(IOpenApiResponse response, string referenceId = null) { EnsureComponentsExist(); EnsureResponsesExist(); @@ -114,7 +114,7 @@ private void AddResponseToComponents(OpenApiResponse response, string referenceI Components.Responses.Add(referenceId, response); } } - private void AddRequestBodyToComponents(OpenApiRequestBody requestBody, string referenceId = null) + private void AddRequestBodyToComponents(IOpenApiRequestBody requestBody, string referenceId = null) { EnsureComponentsExist(); EnsureRequestBodiesExist(); @@ -123,7 +123,7 @@ private void AddRequestBodyToComponents(OpenApiRequestBody requestBody, string r Components.RequestBodies.Add(referenceId, requestBody); } } - private void AddLinkToComponents(OpenApiLink link, string referenceId = null) + private void AddLinkToComponents(IOpenApiLink link, string referenceId = null) { EnsureComponentsExist(); EnsureLinksExist(); @@ -132,7 +132,7 @@ private void AddLinkToComponents(OpenApiLink link, string referenceId = null) Components.Links.Add(referenceId, link); } } - private void AddCallbackToComponents(OpenApiCallback callback, string referenceId = null) + private void AddCallbackToComponents(IOpenApiCallback callback, string referenceId = null) { EnsureComponentsExist(); EnsureCallbacksExist(); @@ -141,7 +141,7 @@ private void AddCallbackToComponents(OpenApiCallback callback, string referenceI Components.Callbacks.Add(referenceId, callback); } } - private void AddHeaderToComponents(OpenApiHeader header, string referenceId = null) + private void AddHeaderToComponents(IOpenApiHeader header, string referenceId = null) { EnsureComponentsExist(); EnsureHeadersExist(); @@ -150,7 +150,7 @@ private void AddHeaderToComponents(OpenApiHeader header, string referenceId = nu Components.Headers.Add(referenceId, header); } } - private void AddExampleToComponents(OpenApiExample example, string referenceId = null) + private void AddExampleToComponents(IOpenApiExample example, string referenceId = null) { EnsureComponentsExist(); EnsureExamplesExist(); @@ -159,7 +159,7 @@ private void AddExampleToComponents(OpenApiExample example, string referenceId = Components.Examples.Add(referenceId, example); } } - private void AddPathItemToComponents(OpenApiPathItem pathItem, string referenceId = null) + private void AddPathItemToComponents(IOpenApiPathItem pathItem, string referenceId = null) { EnsureComponentsExist(); EnsurePathItemsExist(); @@ -168,7 +168,7 @@ private void AddPathItemToComponents(OpenApiPathItem pathItem, string referenceI Components.PathItems.Add(referenceId, pathItem); } } - private void AddSecuritySchemeToComponents(OpenApiSecurityScheme securityScheme, string referenceId = null) + private void AddSecuritySchemeToComponents(IOpenApiSecurityScheme securityScheme, string referenceId = null) { EnsureComponentsExist(); EnsureSecuritySchemesExist(); diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs index 5ad4905a2..d46d33de9 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs @@ -6,6 +6,8 @@ using System.Globalization; using System.IO; using System.Linq; +using System.Text; +using System.Text.Json.Nodes; using System.Threading.Tasks; using FluentAssertions; using Microsoft.OpenApi.Extensions; @@ -1155,6 +1157,154 @@ public async Task ValidateExampleShouldNotHaveDataTypeMismatch() var warnings = result.Diagnostic.Warnings; Assert.False(warnings.Any()); } + const string DoubleHopReferenceSerializedDoc = +""" +{ + "components": { + "schemas": { + "Pet": { + "description": "A pet", + "properties": { + "id": { + "format": "int64", + "type": "integer" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + }, + "type": "object" + }, + "PetReference": { + "$ref": "#/components/schemas/Pet", + "description": "A reference to a pet" + } + } + }, + "info": { + "title": "Pet Store with double hop references", + "version": "1.0.0" + }, + "openapi": "3.1.1", + "paths": { + "/pets": { + "get": { + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PetReference", + "description": "A reference to a pet reference" + } + } + }, + "description": "A list of pets" + } + }, + "summary": "Returns all pets" + } + } + } +} +"""; + [Fact] + public async Task ParsesDoubleHopReferences() + { + + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(DoubleHopReferenceSerializedDoc)); + var (document, _) = await OpenApiDocument.LoadAsync(stream); + Assert.NotNull(document); + + var petReferenceInResponse = Assert.IsType(document.Paths["/pets"].Operations[OperationType.Get].Responses["200"].Content["application/json"].Schema); + Assert.Equal("A reference to a pet reference", petReferenceInResponse.Description, StringComparer.OrdinalIgnoreCase); + var petReference = Assert.IsType(petReferenceInResponse.Target); + Assert.Equal("A reference to a pet", petReference.Description, StringComparer.OrdinalIgnoreCase); + var petReferenceTarget = Assert.IsType(petReference.Target); + Assert.Equal("A pet", petReferenceTarget.Description, StringComparer.OrdinalIgnoreCase); + Assert.Equal(petReferenceTarget, petReferenceInResponse.RecursiveTarget); + } + + [Fact] + public async Task SerializesDoubleHopeReferences() + { + var document = new OpenApiDocument() + { + Info = new OpenApiInfo + { + Title = "Pet Store with double hop references", + Version = "1.0.0" + } + }; + var petSchema = new OpenApiSchema + { + Type = JsonSchemaType.Object, + Description = "A pet", + Properties = + { + ["id"] = new OpenApiSchema + { + Type = JsonSchemaType.Integer, + Format = "int64" + }, + ["name"] = new OpenApiSchema + { + Type = JsonSchemaType.String + }, + ["tag"] = new OpenApiSchema + { + Type = JsonSchemaType.String + } + } + }; + document.AddComponent("Pet", petSchema); + var petSchemaReference = new OpenApiSchemaReference("Pet") + { + Description = "A reference to a pet" + }; + document.AddComponent("PetReference", petSchemaReference); + document.Paths.Add("/pets", new OpenApiPathItem + { + Operations = new Dictionary + { + [OperationType.Get] = new OpenApiOperation + { + Summary = "Returns all pets", + Responses = + { + ["200"] = new OpenApiResponse + { + Description = "A list of pets", + Content = + { + ["application/json"] = new OpenApiMediaType + { + Schema = new OpenApiSchemaReference("PetReference") + { + Description = "A reference to a pet reference" + } + } + } + } + } + } + } + }); + + using var stringWriter = new StringWriter(); + var writer = new OpenApiJsonWriter(stringWriter); + document.SerializeAsV31(writer); + await writer.FlushAsync(); + + var serializedDoc = stringWriter.ToString(); + + Assert.True(JsonNode.DeepEquals( + JsonNode.Parse(serializedDoc), + JsonNode.Parse(DoubleHopReferenceSerializedDoc))); + } [Fact] public async Task ParseDocWithRefsUsingProxyReferencesSucceeds() @@ -1249,6 +1399,7 @@ public async Task ParseDocWithRefsUsingProxyReferencesSucceeds() actualParamReference.Should().BeEquivalentTo(expectedParamReference, options => options .Excluding(x => x.Reference) .Excluding(x => x.Target) + .Excluding(x => x.RecursiveTarget) .Excluding(x => x.Schema.Default.Parent) .Excluding(x => x.Schema.Default.Options) .IgnoringCyclicReferences()); diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index a143a049d..74afafa5a 100644 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -231,7 +231,8 @@ namespace Microsoft.OpenApi.Interfaces public interface IOpenApiReferenceHolder : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReferenceHolder, Microsoft.OpenApi.Interfaces.IOpenApiSerializable where out T : Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, V { - T Target { get; } + T RecursiveTarget { get; } + V Target { get; } V CopyReferenceAsTargetElementWithOverrides(V source); } public interface IOpenApiReferenceable : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { } @@ -338,7 +339,7 @@ namespace Microsoft.OpenApi.MicrosoftExtensions } namespace Microsoft.OpenApi.Models.Interfaces { - public interface IOpenApiCallback : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable + public interface IOpenApiCallback : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable { System.Collections.Generic.Dictionary PathItems { get; } } @@ -346,12 +347,12 @@ namespace Microsoft.OpenApi.Models.Interfaces { string Description { get; set; } } - public interface IOpenApiExample : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiSummarizedElement + public interface IOpenApiExample : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiSummarizedElement { string ExternalValue { get; } System.Text.Json.Nodes.JsonNode Value { get; } } - public interface IOpenApiHeader : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement + public interface IOpenApiHeader : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement { bool AllowEmptyValue { get; } bool AllowReserved { get; } @@ -364,7 +365,7 @@ namespace Microsoft.OpenApi.Models.Interfaces Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema Schema { get; } Microsoft.OpenApi.Models.ParameterStyle? Style { get; } } - public interface IOpenApiLink : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement + public interface IOpenApiLink : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement { string OperationId { get; } string OperationRef { get; } @@ -372,7 +373,7 @@ namespace Microsoft.OpenApi.Models.Interfaces Microsoft.OpenApi.Models.RuntimeExpressionAnyWrapper RequestBody { get; } Microsoft.OpenApi.Models.OpenApiServer Server { get; } } - public interface IOpenApiParameter : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement + public interface IOpenApiParameter : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement { bool AllowEmptyValue { get; } bool AllowReserved { get; } @@ -387,7 +388,7 @@ namespace Microsoft.OpenApi.Models.Interfaces Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema Schema { get; } Microsoft.OpenApi.Models.ParameterStyle? Style { get; } } - public interface IOpenApiPathItem : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiSummarizedElement + public interface IOpenApiPathItem : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiSummarizedElement { System.Collections.Generic.IDictionary Operations { get; } System.Collections.Generic.IList Parameters { get; } @@ -397,20 +398,20 @@ namespace Microsoft.OpenApi.Models.Interfaces { string Description { get; } } - public interface IOpenApiRequestBody : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement + public interface IOpenApiRequestBody : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement { System.Collections.Generic.IDictionary Content { get; } bool Required { get; } Microsoft.OpenApi.Models.Interfaces.IOpenApiParameter ConvertToBodyParameter(Microsoft.OpenApi.Writers.IOpenApiWriter writer); System.Collections.Generic.IEnumerable ConvertToFormDataParameters(Microsoft.OpenApi.Writers.IOpenApiWriter writer); } - public interface IOpenApiResponse : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement + public interface IOpenApiResponse : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement { System.Collections.Generic.IDictionary Content { get; } System.Collections.Generic.IDictionary Headers { get; } System.Collections.Generic.IDictionary Links { get; } } - public interface IOpenApiSchema : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement + public interface IOpenApiSchema : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement { Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema AdditionalProperties { get; } bool AdditionalPropertiesAllowed { get; } @@ -462,7 +463,7 @@ namespace Microsoft.OpenApi.Models.Interfaces bool WriteOnly { get; } Microsoft.OpenApi.Models.OpenApiXml Xml { get; } } - public interface IOpenApiSecurityScheme : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement + public interface IOpenApiSecurityScheme : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement { string BearerFormat { get; } Microsoft.OpenApi.Models.OpenApiOAuthFlows Flows { get; } @@ -476,7 +477,7 @@ namespace Microsoft.OpenApi.Models.Interfaces { string Summary { get; set; } } - public interface IOpenApiTag : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiReadOnlyDescribedElement + public interface IOpenApiTag : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiReadOnlyDescribedElement { Microsoft.OpenApi.Models.OpenApiExternalDocs ExternalDocs { get; } string Name { get; } @@ -1239,19 +1240,20 @@ namespace Microsoft.OpenApi.Models.References { public abstract class BaseOpenApiReferenceHolder : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReferenceHolder, Microsoft.OpenApi.Interfaces.IOpenApiReferenceHolder, Microsoft.OpenApi.Interfaces.IOpenApiSerializable where T : class, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, V - where V : Microsoft.OpenApi.Interfaces.IOpenApiSerializable + where V : Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { protected BaseOpenApiReferenceHolder(Microsoft.OpenApi.Models.References.BaseOpenApiReferenceHolder source) { } protected BaseOpenApiReferenceHolder(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument hostDocument, Microsoft.OpenApi.Models.ReferenceType referenceType, string externalResource) { } + public T RecursiveTarget { get; } public Microsoft.OpenApi.Models.OpenApiReference Reference { get; init; } - public virtual T Target { get; } + public virtual V Target { get; } public bool UnresolvedReference { get; } public abstract V CopyReferenceAsTargetElementWithOverrides(V source); public virtual void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public virtual void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public virtual void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } } - public class OpenApiCallbackReference : Microsoft.OpenApi.Models.References.BaseOpenApiReferenceHolder, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiCallback + public class OpenApiCallbackReference : Microsoft.OpenApi.Models.References.BaseOpenApiReferenceHolder, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiCallback { public OpenApiCallbackReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument hostDocument = null, string externalResource = null) { } public System.Collections.Generic.IDictionary Extensions { get; } @@ -1260,7 +1262,7 @@ namespace Microsoft.OpenApi.Models.References public Microsoft.OpenApi.Models.Interfaces.IOpenApiCallback CreateShallowCopy() { } public override void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } } - public class OpenApiExampleReference : Microsoft.OpenApi.Models.References.BaseOpenApiReferenceHolder, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiExample, Microsoft.OpenApi.Models.Interfaces.IOpenApiSummarizedElement + public class OpenApiExampleReference : Microsoft.OpenApi.Models.References.BaseOpenApiReferenceHolder, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiExample, Microsoft.OpenApi.Models.Interfaces.IOpenApiSummarizedElement { public OpenApiExampleReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument hostDocument = null, string externalResource = null) { } public string Description { get; set; } @@ -1272,7 +1274,7 @@ namespace Microsoft.OpenApi.Models.References public Microsoft.OpenApi.Models.Interfaces.IOpenApiExample CreateShallowCopy() { } public override void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } } - public class OpenApiHeaderReference : Microsoft.OpenApi.Models.References.BaseOpenApiReferenceHolder, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiHeader + public class OpenApiHeaderReference : Microsoft.OpenApi.Models.References.BaseOpenApiReferenceHolder, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiHeader { public OpenApiHeaderReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument hostDocument = null, string externalResource = null) { } public bool AllowEmptyValue { get; } @@ -1290,7 +1292,7 @@ namespace Microsoft.OpenApi.Models.References public override Microsoft.OpenApi.Models.Interfaces.IOpenApiHeader CopyReferenceAsTargetElementWithOverrides(Microsoft.OpenApi.Models.Interfaces.IOpenApiHeader source) { } public Microsoft.OpenApi.Models.Interfaces.IOpenApiHeader CreateShallowCopy() { } } - public class OpenApiLinkReference : Microsoft.OpenApi.Models.References.BaseOpenApiReferenceHolder, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiLink + public class OpenApiLinkReference : Microsoft.OpenApi.Models.References.BaseOpenApiReferenceHolder, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiLink { public OpenApiLinkReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument hostDocument = null, string externalResource = null) { } public string Description { get; set; } @@ -1304,7 +1306,7 @@ namespace Microsoft.OpenApi.Models.References public Microsoft.OpenApi.Models.Interfaces.IOpenApiLink CreateShallowCopy() { } public override void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } } - public class OpenApiParameterReference : Microsoft.OpenApi.Models.References.BaseOpenApiReferenceHolder, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiParameter + public class OpenApiParameterReference : Microsoft.OpenApi.Models.References.BaseOpenApiReferenceHolder, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiParameter { public OpenApiParameterReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument hostDocument = null, string externalResource = null) { } public bool AllowEmptyValue { get; } @@ -1324,7 +1326,7 @@ namespace Microsoft.OpenApi.Models.References public override Microsoft.OpenApi.Models.Interfaces.IOpenApiParameter CopyReferenceAsTargetElementWithOverrides(Microsoft.OpenApi.Models.Interfaces.IOpenApiParameter source) { } public Microsoft.OpenApi.Models.Interfaces.IOpenApiParameter CreateShallowCopy() { } } - public class OpenApiPathItemReference : Microsoft.OpenApi.Models.References.BaseOpenApiReferenceHolder, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiPathItem, Microsoft.OpenApi.Models.Interfaces.IOpenApiSummarizedElement + public class OpenApiPathItemReference : Microsoft.OpenApi.Models.References.BaseOpenApiReferenceHolder, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiPathItem, Microsoft.OpenApi.Models.Interfaces.IOpenApiSummarizedElement { public OpenApiPathItemReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument hostDocument = null, string externalResource = null) { } public string Description { get; set; } @@ -1337,7 +1339,7 @@ namespace Microsoft.OpenApi.Models.References public Microsoft.OpenApi.Models.Interfaces.IOpenApiPathItem CreateShallowCopy() { } public override void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } } - public class OpenApiRequestBodyReference : Microsoft.OpenApi.Models.References.BaseOpenApiReferenceHolder, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiRequestBody + public class OpenApiRequestBodyReference : Microsoft.OpenApi.Models.References.BaseOpenApiReferenceHolder, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiRequestBody { public OpenApiRequestBodyReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument hostDocument = null, string externalResource = null) { } public System.Collections.Generic.IDictionary Content { get; } @@ -1350,7 +1352,7 @@ namespace Microsoft.OpenApi.Models.References public Microsoft.OpenApi.Models.Interfaces.IOpenApiRequestBody CreateShallowCopy() { } public override void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } } - public class OpenApiResponseReference : Microsoft.OpenApi.Models.References.BaseOpenApiReferenceHolder, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiResponse + public class OpenApiResponseReference : Microsoft.OpenApi.Models.References.BaseOpenApiReferenceHolder, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiResponse { public OpenApiResponseReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument hostDocument = null, string externalResource = null) { } public System.Collections.Generic.IDictionary Content { get; } @@ -1361,7 +1363,7 @@ namespace Microsoft.OpenApi.Models.References public override Microsoft.OpenApi.Models.Interfaces.IOpenApiResponse CopyReferenceAsTargetElementWithOverrides(Microsoft.OpenApi.Models.Interfaces.IOpenApiResponse source) { } public Microsoft.OpenApi.Models.Interfaces.IOpenApiResponse CreateShallowCopy() { } } - public class OpenApiSchemaReference : Microsoft.OpenApi.Models.References.BaseOpenApiReferenceHolder, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema + public class OpenApiSchemaReference : Microsoft.OpenApi.Models.References.BaseOpenApiReferenceHolder, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema { public OpenApiSchemaReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument hostDocument = null, string externalResource = null) { } public Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema AdditionalProperties { get; } @@ -1421,7 +1423,7 @@ namespace Microsoft.OpenApi.Models.References public override void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public override void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } } - public class OpenApiSecuritySchemeReference : Microsoft.OpenApi.Models.References.BaseOpenApiReferenceHolder, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiSecurityScheme + public class OpenApiSecuritySchemeReference : Microsoft.OpenApi.Models.References.BaseOpenApiReferenceHolder, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiSecurityScheme { public OpenApiSecuritySchemeReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument hostDocument = null, string externalResource = null) { } public string BearerFormat { get; } @@ -1436,14 +1438,14 @@ namespace Microsoft.OpenApi.Models.References public override Microsoft.OpenApi.Models.Interfaces.IOpenApiSecurityScheme CopyReferenceAsTargetElementWithOverrides(Microsoft.OpenApi.Models.Interfaces.IOpenApiSecurityScheme source) { } public Microsoft.OpenApi.Models.Interfaces.IOpenApiSecurityScheme CreateShallowCopy() { } } - public class OpenApiTagReference : Microsoft.OpenApi.Models.References.BaseOpenApiReferenceHolder, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiReadOnlyDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiTag + public class OpenApiTagReference : Microsoft.OpenApi.Models.References.BaseOpenApiReferenceHolder, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiReadOnlyDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiTag { public OpenApiTagReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument hostDocument = null, string externalResource = null) { } public string Description { get; } public System.Collections.Generic.IDictionary Extensions { get; } public Microsoft.OpenApi.Models.OpenApiExternalDocs ExternalDocs { get; } public string Name { get; } - public override Microsoft.OpenApi.Models.OpenApiTag Target { get; } + public override Microsoft.OpenApi.Models.Interfaces.IOpenApiTag Target { get; } public override Microsoft.OpenApi.Models.Interfaces.IOpenApiTag CopyReferenceAsTargetElementWithOverrides(Microsoft.OpenApi.Models.Interfaces.IOpenApiTag source) { } public Microsoft.OpenApi.Models.Interfaces.IOpenApiTag CreateShallowCopy() { } } From 008d5baffb871cbb5057b046a0be5317c346a296 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Tue, 11 Mar 2025 10:02:43 -0400 Subject: [PATCH 008/984] chore: linting --- src/Microsoft.OpenApi/Models/OpenApiHeader.cs | 2 +- src/Microsoft.OpenApi/Models/OpenApiParameter.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi/Models/OpenApiHeader.cs b/src/Microsoft.OpenApi/Models/OpenApiHeader.cs index 971d88c94..08dd04b99 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiHeader.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiHeader.cs @@ -17,7 +17,7 @@ namespace Microsoft.OpenApi.Models /// Header Object. /// The Header Object follows the structure of the Parameter Object. /// - public class OpenApiHeader : IOpenApiHeader, IOpenApiReferenceable, IOpenApiExtensible + public class OpenApiHeader : IOpenApiHeader, IOpenApiExtensible { /// public string Description { get; set; } diff --git a/src/Microsoft.OpenApi/Models/OpenApiParameter.cs b/src/Microsoft.OpenApi/Models/OpenApiParameter.cs index 40dc918fb..da299e4b5 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiParameter.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiParameter.cs @@ -17,7 +17,7 @@ namespace Microsoft.OpenApi.Models /// /// Parameter Object. /// - public class OpenApiParameter : IOpenApiReferenceable, IOpenApiExtensible, IOpenApiParameter + public class OpenApiParameter : IOpenApiExtensible, IOpenApiParameter { private bool? _explode; private ParameterStyle? _style; From 82bc473ae6527af32c9449e739e778b3abf3d6c1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 11 Mar 2025 21:14:30 +0000 Subject: [PATCH 009/984] chore(deps): bump Microsoft.Extensions.Logging, Microsoft.Extensions.Logging.Abstractions and Microsoft.Extensions.Logging.Console Bumps [Microsoft.Extensions.Logging](https://github.com/dotnet/runtime), [Microsoft.Extensions.Logging.Abstractions](https://github.com/dotnet/runtime) and [Microsoft.Extensions.Logging.Console](https://github.com/dotnet/runtime). These dependencies needed to be updated together. Updates `Microsoft.Extensions.Logging` from 9.0.2 to 9.0.3 - [Release notes](https://github.com/dotnet/runtime/releases) - [Commits](https://github.com/dotnet/runtime/compare/v9.0.2...v9.0.3) Updates `Microsoft.Extensions.Logging.Abstractions` from 9.0.2 to 9.0.3 - [Release notes](https://github.com/dotnet/runtime/releases) - [Commits](https://github.com/dotnet/runtime/compare/v9.0.2...v9.0.3) Updates `Microsoft.Extensions.Logging.Console` from 9.0.2 to 9.0.3 - [Release notes](https://github.com/dotnet/runtime/releases) - [Commits](https://github.com/dotnet/runtime/compare/v9.0.2...v9.0.3) --- updated-dependencies: - dependency-name: Microsoft.Extensions.Logging dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: Microsoft.Extensions.Logging.Abstractions dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: Microsoft.Extensions.Logging.Console dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index 82426e875..60437d3f1 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -28,9 +28,9 @@ - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive From 3d0b406558fe147f9fc2a7a53d4996a7be9651e6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 11 Mar 2025 21:15:18 +0000 Subject: [PATCH 010/984] chore(deps): bump Microsoft.Windows.Compatibility from 9.0.2 to 9.0.3 Bumps [Microsoft.Windows.Compatibility](https://github.com/dotnet/windowsdesktop) from 9.0.2 to 9.0.3. - [Release notes](https://github.com/dotnet/windowsdesktop/releases) - [Commits](https://github.com/dotnet/windowsdesktop/compare/v9.0.2...v9.0.3) --- updated-dependencies: - dependency-name: Microsoft.Windows.Compatibility dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .../Microsoft.OpenApi.Workbench.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj index 03a30916e..4c625efe4 100644 --- a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj +++ b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj @@ -13,7 +13,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - + From a5d86b5390e9481d646821a8170581472fee1fa6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 11 Mar 2025 21:16:03 +0000 Subject: [PATCH 011/984] chore(deps): bump Verify.Xunit from 28.13.0 to 28.14.0 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 28.13.0 to 28.14.0. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/28.13.0...28.14.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 48b38b8c1..922b16e22 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -14,7 +14,7 @@ - + From e6f1e2f5c87bd25c40cb48880398d8e5756a6914 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Wed, 12 Mar 2025 12:35:47 +0300 Subject: [PATCH 012/984] chore: no validation warnings from examples with date-time format --- ...entsTests.cs => OpenApiComponentsTests.cs} | 2 +- .../V31Tests/OpenApiDocumentTests.cs | 15 ++++++++++ ...docWithReferencedExampleInSchemaWorks.yaml | 30 +++++++++++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) rename test/Microsoft.OpenApi.Readers.Tests/V31Tests/{OpenApiCompoentsTests.cs => OpenApiComponentsTests.cs} (97%) create mode 100644 test/Microsoft.OpenApi.Readers.Tests/V31Tests/Samples/OpenApiDocument/docWithReferencedExampleInSchemaWorks.yaml diff --git a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiCompoentsTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiComponentsTests.cs similarity index 97% rename from test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiCompoentsTests.cs rename to test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiComponentsTests.cs index 902d7a910..54f017b44 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiCompoentsTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiComponentsTests.cs @@ -8,7 +8,7 @@ namespace Microsoft.OpenApi.Readers.Tests.V31Tests { - public class OpenApiCompoentsTests + public class OpenApiComponentsTests { [Theory] [InlineData("./FirstLevel/SecondLevel/ThridLevel/File.json#/components/schemas/ExternalRelativePathModel", "ExternalRelativePathModel", "./FirstLevel/SecondLevel/ThridLevel/File.json")] diff --git a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentTests.cs index 3f08158d4..eebebbb6b 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentTests.cs @@ -574,5 +574,20 @@ public void ParseEmptyMemoryStreamThrowsAnArgumentException() { Assert.Throws(() => OpenApiDocument.Load(new MemoryStream())); } + + [Fact] + public async Task ValidateReferencedExampleInSchemaWorks() + { + // Arrange && Act + var path = Path.Combine(SampleFolderPath, "docWithReferencedExampleInSchemaWorks.yaml"); + var result = await OpenApiDocument.LoadAsync(path, SettingsFixture.ReaderSettings); + var actualSchemaExample = result.Document.Components.Schemas["DiffCreatedEvent"].Properties["updatedAt"].Example; + var targetSchemaExample = result.Document.Components.Schemas["Timestamp"].Example; + + // Assert + Assert.Equal(targetSchemaExample, actualSchemaExample); + Assert.Empty(result.Diagnostic.Errors); + Assert.Empty(result.Diagnostic.Warnings); + } } } diff --git a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/Samples/OpenApiDocument/docWithReferencedExampleInSchemaWorks.yaml b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/Samples/OpenApiDocument/docWithReferencedExampleInSchemaWorks.yaml new file mode 100644 index 000000000..2df12cda5 --- /dev/null +++ b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/Samples/OpenApiDocument/docWithReferencedExampleInSchemaWorks.yaml @@ -0,0 +1,30 @@ +openapi: 3.1.1 +info: + title: ReferenceById + version: 1.0.0 +paths: + /resource: + get: + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/DiffCreatedEvent' +components: + schemas: + DiffCreatedEvent: + description: 'diff index created' + type: object + additionalProperties: false + properties: + updatedAt: + $ref: '#/components/schemas/Timestamp' + example: + "updatedAt": '2020-06-30T06:43:51.391Z' + Timestamp: + type: string + format: date-time + description: 'timestamp' + example: '2020-06-30T06:43:51.391Z' \ No newline at end of file From 514dc31b5e496c5957bb62a22799af7a38c71a3a Mon Sep 17 00:00:00 2001 From: Michael Mutunga Date: Wed, 12 Mar 2025 14:45:01 +0300 Subject: [PATCH 013/984] feat/use-http-method-object-instead-of-enum --- README.md | 4 +- .../Formatters/PowerShellFormatter.cs | 5 +- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 4 +- .../Models/Interfaces/IOpenApiPathItem.cs | 5 +- .../Models/OpenApiPathItem.cs | 15 ++-- src/Microsoft.OpenApi/Models/OperationType.cs | 53 ------------ .../References/OpenApiPathItemReference.cs | 3 +- .../Reader/V2/OpenApiPathItemDeserializer.cs | 31 +++---- .../Reader/V3/OpenApiPathItemDeserializer.cs | 17 ++-- .../Reader/V31/OpenApiPathItemDeserializer.cs | 17 ++-- .../Services/OpenApiFilterService.cs | 25 +++--- .../Services/OpenApiVisitorBase.cs | 3 +- .../Services/OpenApiWalker.cs | 7 +- .../Services/OperationSearch.cs | 7 +- .../Validations/OpenApiValidator.cs | 3 +- .../Formatters/PowerShellFormatterTests.cs | 33 +++++--- .../Services/OpenApiFilterServiceTests.cs | 26 +++--- .../Services/OpenApiServiceTests.cs | 4 +- .../UtilityFiles/OpenApiDocumentMock.cs | 84 +++++++++---------- .../V2Tests/OpenApiDocumentTests.cs | 11 +-- .../V2Tests/OpenApiOperationTests.cs | 5 +- .../V2Tests/OpenApiPathItemTests.cs | 13 +-- .../V31Tests/OpenApiDocumentTests.cs | 27 +++--- .../V3Tests/OpenApiCallbackTests.cs | 15 ++-- .../V3Tests/OpenApiDocumentTests.cs | 45 +++++----- .../V3Tests/OpenApiOperationTests.cs | 3 +- .../V3Tests/OpenApiParameterTests.cs | 5 +- .../V3Tests/OpenApiSchemaTests.cs | 5 +- .../Models/OpenApiCallbackTests.cs | 5 +- .../Models/OpenApiComponentsTests.cs | 5 +- .../Models/OpenApiDocumentTests.cs | 65 +++++++------- .../OpenApiCallbackReferenceTests.cs | 5 +- .../OpenApiPathItemReferenceTests.cs | 5 +- .../References/OpenApiTagReferenceTest.cs | 3 +- .../PublicApi/PublicApi.approved.txt | 39 +++------ .../Services/OpenApiUrlTreeNodeTests.cs | 35 ++++---- .../Services/OpenApiValidatorTests.cs | 3 +- .../OpenApiReferenceValidationTests.cs | 9 +- .../Visitors/InheritanceTests.cs | 5 +- .../Walkers/WalkerLocationTests.cs | 11 +-- .../Workspaces/OpenApiWorkspaceTests.cs | 7 +- .../Writers/OpenApiYamlWriterTests.cs | 5 +- 42 files changed, 319 insertions(+), 358 deletions(-) delete mode 100644 src/Microsoft.OpenApi/Models/OperationType.cs diff --git a/README.md b/README.md index 02235604a..a18c00723 100644 --- a/README.md +++ b/README.md @@ -55,9 +55,9 @@ var document = new OpenApiDocument { ["/pets"] = new OpenApiPathItem { - Operations = new Dictionary + Operations = new Dictionary { - [OperationType.Get] = new OpenApiOperation + [HttpMethod.Get] = new OpenApiOperation { Description = "Returns all pets from the system that the user has access to", Responses = new OpenApiResponses diff --git a/src/Microsoft.OpenApi.Hidi/Formatters/PowerShellFormatter.cs b/src/Microsoft.OpenApi.Hidi/Formatters/PowerShellFormatter.cs index df632b78a..f263dae0e 100644 --- a/src/Microsoft.OpenApi.Hidi/Formatters/PowerShellFormatter.cs +++ b/src/Microsoft.OpenApi.Hidi/Formatters/PowerShellFormatter.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Net.Http; using System.Text; using System.Text.RegularExpressions; using Humanizer; @@ -53,11 +54,11 @@ public override void Visit(IOpenApiSchema schema) public override void Visit(IOpenApiPathItem pathItem) { - if (pathItem.Operations.TryGetValue(OperationType.Put, out var value) && + if (pathItem.Operations.TryGetValue(HttpMethod.Put, out var value) && value.OperationId != null) { var operationId = value.OperationId; - pathItem.Operations[OperationType.Put].OperationId = ResolvePutOperationId(operationId); + pathItem.Operations[HttpMethod.Put].OperationId = ResolvePutOperationId(operationId); } base.Visit(pathItem); diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index 692e35c0d..e0cce5896 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -256,9 +256,9 @@ private static async Task GetOpenApiAsync(HidiOptions options, return document; } - private static Func? FilterOpenApiDocument(string? filterByOperationIds, string? filterByTags, Dictionary> requestUrls, OpenApiDocument document, ILogger logger) + private static Func? FilterOpenApiDocument(string? filterByOperationIds, string? filterByTags, Dictionary> requestUrls, OpenApiDocument document, ILogger logger) { - Func? predicate = null; + Func? predicate = null; using (logger.BeginScope("Create Filter")) { diff --git a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiPathItem.cs b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiPathItem.cs index fe0d5bdef..d69f06473 100644 --- a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiPathItem.cs +++ b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiPathItem.cs @@ -1,5 +1,6 @@ - + using System.Collections.Generic; +using System.Net.Http; using Microsoft.OpenApi.Interfaces; namespace Microsoft.OpenApi.Models.Interfaces; @@ -13,7 +14,7 @@ public interface IOpenApiPathItem : IOpenApiDescribedElement, IOpenApiSummarized /// /// Gets the definition of operations on this path. /// - public IDictionary Operations { get; } + public IDictionary Operations { get; } /// /// An alternative server array to service all operations in this path. diff --git a/src/Microsoft.OpenApi/Models/OpenApiPathItem.cs b/src/Microsoft.OpenApi/Models/OpenApiPathItem.cs index f3baa5743..1d4be44ad 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiPathItem.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiPathItem.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Net.Http; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models.Interfaces; @@ -22,8 +23,8 @@ public class OpenApiPathItem : IOpenApiExtensible, IOpenApiReferenceable, IOpenA public string Description { get; set; } /// - public IDictionary Operations { get; set; } - = new Dictionary(); + public IDictionary Operations { get; set; } + = new Dictionary(); /// public IList Servers { get; set; } = []; @@ -39,7 +40,7 @@ public class OpenApiPathItem : IOpenApiExtensible, IOpenApiReferenceable, IOpenA /// /// The operation type kind. /// The operation item. - public void AddOperation(OperationType operationType, OpenApiOperation operation) + public void AddOperation(HttpMethod operationType, OpenApiOperation operation) { Operations[operationType] = operation; } @@ -57,7 +58,7 @@ internal OpenApiPathItem(IOpenApiPathItem pathItem) Utils.CheckArgumentNull(pathItem); Summary = pathItem.Summary ?? Summary; Description = pathItem.Description ?? Description; - Operations = pathItem.Operations != null ? new Dictionary(pathItem.Operations) : null; + Operations = pathItem.Operations != null ? new Dictionary(pathItem.Operations) : null; Servers = pathItem.Servers != null ? new List(pathItem.Servers) : null; Parameters = pathItem.Parameters != null ? new List(pathItem.Parameters) : null; Extensions = pathItem.Extensions != null ? new Dictionary(pathItem.Extensions) : null; @@ -92,10 +93,10 @@ public void SerializeAsV2(IOpenApiWriter writer) // operations except "trace" foreach (var operation in Operations) { - if (operation.Key != OperationType.Trace) + if (operation.Key != HttpMethod.Trace) { writer.WriteOptionalObject( - operation.Key.GetDisplayName(), + operation.Key.Method.ToLowerInvariant(), operation.Value, (w, o) => o.SerializeAsV2(w)); } @@ -135,7 +136,7 @@ internal virtual void SerializeInternal(IOpenApiWriter writer, OpenApiSpecVersio foreach (var operation in Operations) { writer.WriteOptionalObject( - operation.Key.GetDisplayName(), + operation.Key.Method.ToLowerInvariant(), operation.Value, callback); } diff --git a/src/Microsoft.OpenApi/Models/OperationType.cs b/src/Microsoft.OpenApi/Models/OperationType.cs deleted file mode 100644 index ed3457353..000000000 --- a/src/Microsoft.OpenApi/Models/OperationType.cs +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. - -using Microsoft.OpenApi.Attributes; - -namespace Microsoft.OpenApi.Models -{ - /// - /// Operation type. - /// - public enum OperationType - { - /// - /// A definition of a GET operation on this path. - /// - [Display("get")] Get, - - /// - /// A definition of a PUT operation on this path. - /// - [Display("put")] Put, - - /// - /// A definition of a POST operation on this path. - /// - [Display("post")] Post, - - /// - /// A definition of a DELETE operation on this path. - /// - [Display("delete")] Delete, - - /// - /// A definition of a OPTIONS operation on this path. - /// - [Display("options")] Options, - - /// - /// A definition of a HEAD operation on this path. - /// - [Display("head")] Head, - - /// - /// A definition of a PATCH operation on this path. - /// - [Display("patch")] Patch, - - /// - /// A definition of a TRACE operation on this path. - /// - [Display("trace")] Trace - } -} diff --git a/src/Microsoft.OpenApi/Models/References/OpenApiPathItemReference.cs b/src/Microsoft.OpenApi/Models/References/OpenApiPathItemReference.cs index 038e1cb13..d56d07c21 100644 --- a/src/Microsoft.OpenApi/Models/References/OpenApiPathItemReference.cs +++ b/src/Microsoft.OpenApi/Models/References/OpenApiPathItemReference.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. using System.Collections.Generic; +using System.Net.Http; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models.Interfaces; using Microsoft.OpenApi.Writers; @@ -64,7 +65,7 @@ public string Description } /// - public IDictionary Operations { get => Target?.Operations; } + public IDictionary Operations { get => Target?.Operations; } /// public IList Servers { get => Target?.Servers; } diff --git a/src/Microsoft.OpenApi/Reader/V2/OpenApiPathItemDeserializer.cs b/src/Microsoft.OpenApi/Reader/V2/OpenApiPathItemDeserializer.cs index b1e0da7a8..579e968a2 100644 --- a/src/Microsoft.OpenApi/Reader/V2/OpenApiPathItemDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V2/OpenApiPathItemDeserializer.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Net.Http; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Reader.ParseNodes; @@ -18,13 +19,13 @@ internal static partial class OpenApiV2Deserializer { private static readonly FixedFieldMap _pathItemFixedFields = new() { - {"get", (o, n, t) => o.AddOperation(OperationType.Get, LoadOperation(n, t))}, - {"put", (o, n, t) => o.AddOperation(OperationType.Put, LoadOperation(n, t))}, - {"post", (o, n, t) => o.AddOperation(OperationType.Post, LoadOperation(n, t))}, - {"delete", (o, n, t) => o.AddOperation(OperationType.Delete, LoadOperation(n, t))}, - {"options", (o, n, t) => o.AddOperation(OperationType.Options, LoadOperation(n, t))}, - {"head", (o, n, t) => o.AddOperation(OperationType.Head, LoadOperation(n, t))}, - {"patch", (o, n, t) => o.AddOperation(OperationType.Patch, LoadOperation(n, t))}, + {"get", (o, n, t) => o.AddOperation(HttpMethod.Get, LoadOperation(n, t))}, + {"put", (o, n, t) => o.AddOperation(HttpMethod.Put, LoadOperation(n, t))}, + {"post", (o, n, t) => o.AddOperation(HttpMethod.Post, LoadOperation(n, t))}, + {"delete", (o, n, t) => o.AddOperation(HttpMethod.Delete, LoadOperation(n, t))}, + {"options", (o, n, t) => o.AddOperation(HttpMethod.Options, LoadOperation(n, t))}, + {"head", (o, n, t) => o.AddOperation(HttpMethod.Head, LoadOperation(n, t))}, + {"patch", (o, n, t) => o.AddOperation(new HttpMethod("PATCH"), LoadOperation(n, t))}, { "parameters", LoadPathParameters @@ -62,13 +63,9 @@ private static void LoadPathParameters(OpenApiPathItem pathItem, ParseNode node, var requestBody = CreateRequestBody(node.Context, bodyParameter); foreach (var opPair in pathItem.Operations.Where(x => x.Value.RequestBody is null)) { - switch (opPair.Key) + if (opPair.Key == HttpMethod.Post || opPair.Key == HttpMethod.Put || opPair.Key == new HttpMethod("PATCH")) { - case OperationType.Post: - case OperationType.Put: - case OperationType.Patch: - opPair.Value.RequestBody = requestBody; - break; + opPair.Value.RequestBody = requestBody; } } } @@ -80,13 +77,9 @@ private static void LoadPathParameters(OpenApiPathItem pathItem, ParseNode node, var requestBody = CreateFormBody(node.Context, formParameters); foreach (var opPair in pathItem.Operations.Where(x => x.Value.RequestBody is null)) { - switch (opPair.Key) + if (opPair.Key == HttpMethod.Post || opPair.Key == HttpMethod.Put || opPair.Key == new HttpMethod("PATCH")) { - case OperationType.Post: - case OperationType.Put: - case OperationType.Patch: - opPair.Value.RequestBody = requestBody; - break; + opPair.Value.RequestBody = requestBody; } } } diff --git a/src/Microsoft.OpenApi/Reader/V3/OpenApiPathItemDeserializer.cs b/src/Microsoft.OpenApi/Reader/V3/OpenApiPathItemDeserializer.cs index baaf5babc..b81f2d45d 100644 --- a/src/Microsoft.OpenApi/Reader/V3/OpenApiPathItemDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V3/OpenApiPathItemDeserializer.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. using System; +using System.Net.Http; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.Interfaces; @@ -26,14 +27,14 @@ internal static partial class OpenApiV3Deserializer "description", (o, n, _) => o.Description = n.GetScalarValue() }, - {"get", (o, n, t) => o.AddOperation(OperationType.Get, LoadOperation(n, t))}, - {"put", (o, n, t) => o.AddOperation(OperationType.Put, LoadOperation(n, t))}, - {"post", (o, n, t) => o.AddOperation(OperationType.Post, LoadOperation(n, t))}, - {"delete", (o, n, t) => o.AddOperation(OperationType.Delete, LoadOperation(n, t))}, - {"options", (o, n, t) => o.AddOperation(OperationType.Options, LoadOperation(n, t))}, - {"head", (o, n, t) => o.AddOperation(OperationType.Head, LoadOperation(n, t))}, - {"patch", (o, n, t) => o.AddOperation(OperationType.Patch, LoadOperation(n, t))}, - {"trace", (o, n, t) => o.AddOperation(OperationType.Trace, LoadOperation(n, t))}, + {"get", (o, n, t) => o.AddOperation(HttpMethod.Get, LoadOperation(n, t))}, + {"put", (o, n, t) => o.AddOperation(HttpMethod.Put, LoadOperation(n, t))}, + {"post", (o, n, t) => o.AddOperation(HttpMethod.Post, LoadOperation(n, t))}, + {"delete", (o, n, t) => o.AddOperation(HttpMethod.Delete, LoadOperation(n, t))}, + {"options", (o, n, t) => o.AddOperation(HttpMethod.Options, LoadOperation(n, t))}, + {"head", (o, n, t) => o.AddOperation(HttpMethod.Head, LoadOperation(n, t))}, + {"patch", (o, n, t) => o.AddOperation(new HttpMethod("PATCH"), LoadOperation(n, t))}, + {"trace", (o, n, t) => o.AddOperation(HttpMethod.Trace, LoadOperation(n, t))}, {"servers", (o, n, t) => o.Servers = n.CreateList(LoadServer, t)}, {"parameters", (o, n, t) => o.Parameters = n.CreateList(LoadParameter, t)} }; diff --git a/src/Microsoft.OpenApi/Reader/V31/OpenApiPathItemDeserializer.cs b/src/Microsoft.OpenApi/Reader/V31/OpenApiPathItemDeserializer.cs index 391a34bf6..9f9b644d7 100644 --- a/src/Microsoft.OpenApi/Reader/V31/OpenApiPathItemDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V31/OpenApiPathItemDeserializer.cs @@ -1,4 +1,5 @@ using System; +using System.Net.Http; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.Interfaces; @@ -28,14 +29,14 @@ internal static partial class OpenApiV31Deserializer o.Description = n.GetScalarValue(); } }, - {"get", (o, n, t) => o.AddOperation(OperationType.Get, LoadOperation(n, t))}, - {"put", (o, n, t) => o.AddOperation(OperationType.Put, LoadOperation(n, t))}, - {"post", (o, n, t) => o.AddOperation(OperationType.Post, LoadOperation(n, t))}, - {"delete", (o, n, t) => o.AddOperation(OperationType.Delete, LoadOperation(n, t))}, - {"options", (o, n, t) => o.AddOperation(OperationType.Options, LoadOperation(n, t))}, - {"head", (o, n, t) => o.AddOperation(OperationType.Head, LoadOperation(n, t))}, - {"patch", (o, n, t) => o.AddOperation(OperationType.Patch, LoadOperation(n, t))}, - {"trace", (o, n, t) => o.AddOperation(OperationType.Trace, LoadOperation(n, t))}, + {"get", (o, n, t) => o.AddOperation(HttpMethod.Get, LoadOperation(n, t))}, + {"put", (o, n, t) => o.AddOperation(HttpMethod.Put, LoadOperation(n, t))}, + {"post", (o, n, t) => o.AddOperation(HttpMethod.Post, LoadOperation(n, t))}, + {"delete", (o, n, t) => o.AddOperation(HttpMethod.Delete, LoadOperation(n, t))}, + {"options", (o, n, t) => o.AddOperation(HttpMethod.Options, LoadOperation(n, t))}, + {"head", (o, n, t) => o.AddOperation(HttpMethod.Head, LoadOperation(n, t))}, + {"patch", (o, n, t) => o.AddOperation(new HttpMethod("PATCH"), LoadOperation(n, t))}, + {"trace", (o, n, t) => o.AddOperation(HttpMethod.Trace, LoadOperation(n, t))}, {"servers", (o, n, t) => o.Servers = n.CreateList(LoadServer, t)}, {"parameters", (o, n, t) => o.Parameters = n.CreateList(LoadParameter, t)} }; diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs index 448542c10..1e109a41d 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs @@ -1,10 +1,11 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; +using System.Net.Http; using System.Text.RegularExpressions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.Interfaces; @@ -25,13 +26,13 @@ public static class OpenApiFilterService /// A dictionary of requests from a postman collection. /// The input OpenAPI document. /// A predicate. - public static Func CreatePredicate( + public static Func CreatePredicate( string operationIds = null, string tags = null, Dictionary> requestUrls = null, OpenApiDocument source = null) { - Func predicate; + Func predicate; ValidateFilters(requestUrls, operationIds, tags); if (operationIds != null) { @@ -59,7 +60,7 @@ public static class OpenApiFilterService /// The target . /// A predicate function. /// A partial OpenAPI document. - public static OpenApiDocument CreateFilteredDocument(OpenApiDocument source, Func predicate) + public static OpenApiDocument CreateFilteredDocument(OpenApiDocument source, Func predicate) { // Fetch and copy title, graphVersion and server info from OpenApiDoc var components = source.Components is null @@ -107,7 +108,7 @@ public static OpenApiDocument CreateFilteredDocument(OpenApiDocument source, Fun if (result.CurrentKeys.Operation != null) { - pathItem.Operations.Add((OperationType)result.CurrentKeys.Operation, result.Operation); + pathItem.Operations.Add((HttpMethod)result.CurrentKeys.Operation, result.Operation); if (result.Parameters?.Any() ?? false) { @@ -147,7 +148,7 @@ public static OpenApiUrlTreeNode CreateOpenApiUrlTreeNode(Dictionary GetOpenApiOperations(OpenApiUrlTreeNode rootNode, string relativeUrl, string label) + private static IDictionary GetOpenApiOperations(OpenApiUrlTreeNode rootNode, string relativeUrl, string label) { if (relativeUrl.Equals("/", StringComparison.Ordinal) && rootNode.HasOperations(label)) { @@ -156,7 +157,7 @@ private static IDictionary GetOpenApiOperations var urlSegments = relativeUrl.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries); - IDictionary operations = null; + IDictionary operations = null; var targetChild = rootNode; @@ -224,7 +225,7 @@ private static IDictionary GetOpenApiOperations return operations; } - private static IList FindOperations(OpenApiDocument sourceDocument, Func predicate) + private static IList FindOperations(OpenApiDocument sourceDocument, Func predicate) { var search = new OperationSearch(predicate); var walker = new OpenApiWalker(search); @@ -344,7 +345,7 @@ private static void ValidateFilters(IDictionary> requestUrl } } - private static Func GetOperationIdsPredicate(string operationIds) + private static Func GetOperationIdsPredicate(string operationIds) { if (operationIds == "*") { @@ -357,7 +358,7 @@ private static void ValidateFilters(IDictionary> requestUrl } } - private static Func GetTagsPredicate(string tags) + private static Func GetTagsPredicate(string tags) { var tagsArray = tags.Split(','); if (tagsArray.Length == 1) @@ -371,7 +372,7 @@ private static void ValidateFilters(IDictionary> requestUrl } } - private static Func GetRequestUrlsPredicate(Dictionary> requestUrls, OpenApiDocument source) + private static Func GetRequestUrlsPredicate(Dictionary> requestUrls, OpenApiDocument source) { var operationTypes = new List(); if (source != null) @@ -404,7 +405,7 @@ private static void ValidateFilters(IDictionary> requestUrl return (path, operationType, _) => operationTypes.Contains(operationType + path); } - private static List GetOperationTypes(IDictionary openApiOperations, List url, string path) + private static List GetOperationTypes(IDictionary openApiOperations, List url, string path) { // Add the available ops if they are in the postman collection. See path.Value return openApiOperations.Where(ops => url.Contains(ops.Key.ToString().ToUpper())) diff --git a/src/Microsoft.OpenApi/Services/OpenApiVisitorBase.cs b/src/Microsoft.OpenApi/Services/OpenApiVisitorBase.cs index e4420c3c3..aae8527d7 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiVisitorBase.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiVisitorBase.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Net.Http; using System.Text.Json.Nodes; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; @@ -127,7 +128,7 @@ public virtual void Visit(OpenApiServerVariable serverVariable) /// /// Visits the operations. /// - public virtual void Visit(IDictionary operations) + public virtual void Visit(IDictionary operations) { } diff --git a/src/Microsoft.OpenApi/Services/OpenApiWalker.cs b/src/Microsoft.OpenApi/Services/OpenApiWalker.cs index 76947f381..b9b053c96 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiWalker.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiWalker.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Net.Http; using System.Text.Json.Nodes; using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Extensions; @@ -561,7 +562,7 @@ internal void Walk(IOpenApiPathItem pathItem, bool isComponent = false) /// /// Visits dictionary of /// - internal void Walk(IDictionary operations) + internal void Walk(IDictionary operations) { if (operations == null) { @@ -574,7 +575,7 @@ internal void Walk(IDictionary operations) foreach (var operation in operations) { _visitor.CurrentKeys.Operation = operation.Key; - Walk(operation.Key.GetDisplayName(), () => Walk(operation.Value)); + Walk(operation.Key.Method.ToLowerInvariant(), () => Walk(operation.Value)); _visitor.CurrentKeys.Operation = null; } } @@ -1262,7 +1263,7 @@ public class CurrentKeys /// /// Current Operation Type /// - public OperationType? Operation { get; set; } + public HttpMethod Operation { get; set; } /// /// Current Response Status Code diff --git a/src/Microsoft.OpenApi/Services/OperationSearch.cs b/src/Microsoft.OpenApi/Services/OperationSearch.cs index c726ac966..d3199f38c 100644 --- a/src/Microsoft.OpenApi/Services/OperationSearch.cs +++ b/src/Microsoft.OpenApi/Services/OperationSearch.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Net.Http; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.Interfaces; @@ -14,7 +15,7 @@ namespace Microsoft.OpenApi.Services /// public class OperationSearch : OpenApiVisitorBase { - private readonly Func _predicate; + private readonly Func _predicate; private readonly List _searchResults = new(); /// @@ -26,7 +27,7 @@ public class OperationSearch : OpenApiVisitorBase /// The OperationSearch constructor. /// /// A predicate function. - public OperationSearch(Func predicate) + public OperationSearch(Func predicate) { _predicate = predicate ?? throw new ArgumentNullException(nameof(predicate)); } @@ -70,7 +71,7 @@ public override void Visit(IList parameters) base.Visit(parameters); } - private static CurrentKeys CopyCurrentKeys(CurrentKeys currentKeys, OperationType operationType) + private static CurrentKeys CopyCurrentKeys(CurrentKeys currentKeys, HttpMethod operationType) { return new() { diff --git a/src/Microsoft.OpenApi/Validations/OpenApiValidator.cs b/src/Microsoft.OpenApi/Validations/OpenApiValidator.cs index 784f06172..734c514c3 100644 --- a/src/Microsoft.OpenApi/Validations/OpenApiValidator.cs +++ b/src/Microsoft.OpenApi/Validations/OpenApiValidator.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; +using System.Net.Http; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.Interfaces; @@ -155,7 +156,7 @@ public void AddWarning(OpenApiValidatorWarning warning) /// public override void Visit(OpenApiOperation operation) => Validate(operation); /// - public override void Visit(IDictionary operations) => Validate(operations, operations.GetType()); + public override void Visit(IDictionary operations) => Validate(operations, operations.GetType()); /// public override void Visit(IDictionary headers) => Validate(headers, headers.GetType()); /// diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Formatters/PowerShellFormatterTests.cs b/test/Microsoft.OpenApi.Hidi.Tests/Formatters/PowerShellFormatterTests.cs index da6d8c61e..49b020a10 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Formatters/PowerShellFormatterTests.cs +++ b/test/Microsoft.OpenApi.Hidi.Tests/Formatters/PowerShellFormatterTests.cs @@ -10,16 +10,23 @@ namespace Microsoft.OpenApi.Hidi.Tests.Formatters { public class PowerShellFormatterTests { + public static IEnumerable TestCases + { + get + { + yield return new object[] { "drives.drive.ListDrive", "drive_ListDrive", HttpMethod.Get }; + yield return new object[] { "print.taskDefinitions.tasks.GetTrigger", "print.taskDefinition.task_GetTrigger", HttpMethod.Get }; + yield return new object[] { "groups.sites.termStore.groups.GetSets", "group.site.termStore.group_GetSet", HttpMethod.Get }; + yield return new object[] { "external.industryData.ListDataConnectors", "external.industryData_ListDataConnector", HttpMethod.Get }; + yield return new object[] { "applications.application.UpdateLogo", "application_SetLogo", HttpMethod.Put }; + yield return new object[] { "identityGovernance.lifecycleWorkflows.workflows.workflow.activate", "identityGovernance.lifecycleWorkflow.workflow_activate", HttpMethod.Post }; + yield return new object[] { "directory.GetDeletedItems.AsApplication", "directory_GetDeletedItemAsApplication", HttpMethod.Get }; + yield return new object[] { "education.users.GetCount-6be9", "education.user_GetCount", HttpMethod.Get }; + } + } [Theory] - [InlineData("drives.drive.ListDrive", "drive_ListDrive", OperationType.Get)] - [InlineData("print.taskDefinitions.tasks.GetTrigger", "print.taskDefinition.task_GetTrigger", OperationType.Get)] - [InlineData("groups.sites.termStore.groups.GetSets", "group.site.termStore.group_GetSet", OperationType.Get)] - [InlineData("external.industryData.ListDataConnectors", "external.industryData_ListDataConnector", OperationType.Get)] - [InlineData("applications.application.UpdateLogo", "application_SetLogo", OperationType.Put)] - [InlineData("identityGovernance.lifecycleWorkflows.workflows.workflow.activate", "identityGovernance.lifecycleWorkflow.workflow_activate", OperationType.Post)] - [InlineData("directory.GetDeletedItems.AsApplication", "directory_GetDeletedItemAsApplication", OperationType.Get)] - [InlineData("education.users.GetCount-6be9", "education.user_GetCount", OperationType.Get)] - public void FormatOperationIdsInOpenAPIDocument(string operationId, string expectedOperationId, OperationType operationType, string path = "/foo") + [MemberData(nameof(TestCases))] + public void FormatOperationIdsInOpenAPIDocument(string operationId, string expectedOperationId, HttpMethod operationType, string path = "/foo") { // Arrange var openApiDocument = new OpenApiDocument @@ -29,7 +36,7 @@ public void FormatOperationIdsInOpenAPIDocument(string operationId, string expec Paths = new() { { path, new OpenApiPathItem() { - Operations = new Dictionary + Operations = new Dictionary { { operationType, new() { OperationId = operationId } } } @@ -89,7 +96,7 @@ public void ResolveFunctionParameters() var walker = new OpenApiWalker(powerShellFormatter); walker.Walk(openApiDocument); - var idsParameter = openApiDocument.Paths["/foo"].Operations[OperationType.Get].Parameters?.Where(static p => p.Name == "ids").FirstOrDefault(); + var idsParameter = openApiDocument.Paths["/foo"].Operations[HttpMethod.Get].Parameters?.Where(static p => p.Name == "ids").FirstOrDefault(); // Assert Assert.Null(idsParameter?.Content); @@ -106,10 +113,10 @@ private static OpenApiDocument GetSampleOpenApiDocument() Paths = new() { { "/foo", new OpenApiPathItem() { - Operations = new Dictionary + Operations = new Dictionary { { - OperationType.Get, new() + HttpMethod.Get, new() { OperationId = "Foo.GetFoo", Parameters = diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs index 753f2e9d9..57d2d5098 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs +++ b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs @@ -83,11 +83,11 @@ public void TestPredicateFiltersUsingRelativeRequestUrls() Paths = new() { {"/foo", new OpenApiPathItem() { - Operations = new Dictionary + Operations = new Dictionary { - { OperationType.Get, new() }, - { OperationType.Patch, new() }, - { OperationType.Post, new() } + { HttpMethod.Get, new() }, + { HttpMethod.Patch, new() }, + { HttpMethod.Post, new() } } } } @@ -104,9 +104,9 @@ public void TestPredicateFiltersUsingRelativeRequestUrls() var predicate = OpenApiFilterService.CreatePredicate(requestUrls: requestUrls, source: openApiDocument); // Then - Assert.True(predicate("/foo", OperationType.Get, null)); - Assert.True(predicate("/foo", OperationType.Post, null)); - Assert.False(predicate("/foo", OperationType.Patch, null)); + Assert.True(predicate("/foo", HttpMethod.Get, null)); + Assert.True(predicate("/foo", HttpMethod.Post, null)); + Assert.False(predicate("/foo", HttpMethod.Patch, null)); } [Fact] @@ -121,10 +121,10 @@ public void CreateFilteredDocumentUsingPredicateFromRequestUrl() { ["/test/{id}"] = new OpenApiPathItem() { - Operations = new Dictionary + Operations = new Dictionary { - { OperationType.Get, new() }, - { OperationType.Patch, new() } + { HttpMethod.Get, new() }, + { HttpMethod.Patch, new() } }, Parameters = [ @@ -241,7 +241,7 @@ public async Task CopiesOverAllReferencedComponentsToTheSubsetDocumentCorrectly( var doc = (await OpenApiDocument.LoadAsync(stream, "yaml", settings)).Document; // validated the tags are read as references - var openApiOperationTags = doc.Paths["/items"].Operations[OperationType.Get].Tags?.ToArray(); + var openApiOperationTags = doc.Paths["/items"].Operations[HttpMethod.Get].Tags?.ToArray(); Assert.NotNull(openApiOperationTags); Assert.Single(openApiOperationTags); Assert.True(openApiOperationTags[0].UnresolvedReference); @@ -249,7 +249,7 @@ public async Task CopiesOverAllReferencedComponentsToTheSubsetDocumentCorrectly( var predicate = OpenApiFilterService.CreatePredicate(operationIds: operationIds); var subsetOpenApiDocument = OpenApiFilterService.CreateFilteredDocument(doc, predicate); - var response = subsetOpenApiDocument.Paths["/items"].Operations[OperationType.Get]?.Responses?["200"]; + var response = subsetOpenApiDocument.Paths["/items"].Operations[HttpMethod.Get]?.Responses?["200"]; var responseHeader = response?.Headers["x-custom-header"]; var mediaTypeExample = response?.Content["application/json"]?.Examples?.First().Value; var targetHeaders = subsetOpenApiDocument.Components?.Headers; @@ -266,7 +266,7 @@ public async Task CopiesOverAllReferencedComponentsToTheSubsetDocumentCorrectly( Assert.NotNull(targetExamples); Assert.Single(targetExamples); // validated the tags of the trimmed document are read as references - var trimmedOpenApiOperationTags = subsetOpenApiDocument.Paths["/items"].Operations[OperationType.Get].Tags?.ToArray(); + var trimmedOpenApiOperationTags = subsetOpenApiDocument.Paths["/items"].Operations[HttpMethod.Get].Tags?.ToArray(); Assert.NotNull(trimmedOpenApiOperationTags); Assert.Single(trimmedOpenApiOperationTags); Assert.True(trimmedOpenApiOperationTags[0].UnresolvedReference); diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs index c23222eb6..ec306bc55 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs +++ b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs @@ -45,9 +45,9 @@ public void CreateFilteredDocumentOnMinimalOpenApi() { ["/test"] = new OpenApiPathItem() { - Operations = new Dictionary + Operations = new Dictionary { - [OperationType.Get] = new OpenApiOperation() + [HttpMethod.Get] = new OpenApiOperation() } } } diff --git a/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/OpenApiDocumentMock.cs b/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/OpenApiDocumentMock.cs index 0da220427..0cc1bc2fb 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/OpenApiDocumentMock.cs +++ b/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/OpenApiDocumentMock.cs @@ -51,10 +51,10 @@ public static OpenApiDocument CreateOpenApiDocument() { ["/"] = new OpenApiPathItem() // root path { - Operations = new Dictionary + Operations = new Dictionary { { - OperationType.Get, new OpenApiOperation + HttpMethod.Get, new OpenApiOperation { OperationId = "graphService.GetGraphService", Responses = new() @@ -72,10 +72,10 @@ public static OpenApiDocument CreateOpenApiDocument() }, [getTeamsActivityByPeriodPath] = new OpenApiPathItem() { - Operations = new Dictionary + Operations = new Dictionary { { - OperationType.Get, new OpenApiOperation + HttpMethod.Get, new OpenApiOperation { OperationId = "reports.getTeamsUserActivityCounts", Summary = "Invoke function getTeamsUserActivityUserCounts", @@ -137,10 +137,10 @@ public static OpenApiDocument CreateOpenApiDocument() }, [getTeamsActivityByDatePath] = new OpenApiPathItem() { - Operations = new Dictionary + Operations = new Dictionary { { - OperationType.Get, new OpenApiOperation + HttpMethod.Get, new OpenApiOperation { OperationId = "reports.getTeamsUserActivityUserDetail-a3f1", Summary = "Invoke function getTeamsUserActivityUserDetail", @@ -200,10 +200,10 @@ public static OpenApiDocument CreateOpenApiDocument() }, [usersPath] = new OpenApiPathItem() { - Operations = new Dictionary + Operations = new Dictionary { { - OperationType.Get, new OpenApiOperation + HttpMethod.Get, new OpenApiOperation { OperationId = "users.user.ListUser", Summary = "Get entities from users", @@ -246,10 +246,10 @@ public static OpenApiDocument CreateOpenApiDocument() }, [usersByIdPath] = new OpenApiPathItem() { - Operations = new Dictionary + Operations = new Dictionary { { - OperationType.Get, new OpenApiOperation + HttpMethod.Get, new OpenApiOperation { OperationId = "users.user.GetUser", Summary = "Get entity from users by key", @@ -274,7 +274,7 @@ public static OpenApiDocument CreateOpenApiDocument() } }, { - OperationType.Patch, new OpenApiOperation + HttpMethod.Patch, new OpenApiOperation { OperationId = "users.user.UpdateUser", Summary = "Update entity in users", @@ -293,10 +293,10 @@ public static OpenApiDocument CreateOpenApiDocument() }, [messagesByIdPath] = new OpenApiPathItem() { - Operations = new Dictionary + Operations = new Dictionary { { - OperationType.Get, new OpenApiOperation + HttpMethod.Get, new OpenApiOperation { OperationId = "users.GetMessages", Summary = "Get messages from users", @@ -340,10 +340,10 @@ public static OpenApiDocument CreateOpenApiDocument() }, [administrativeUnitRestorePath] = new OpenApiPathItem() { - Operations = new Dictionary + Operations = new Dictionary { { - OperationType.Post, new OpenApiOperation + HttpMethod.Post, new OpenApiOperation { OperationId = "administrativeUnits.restore", Summary = "Invoke action restore", @@ -391,10 +391,10 @@ public static OpenApiDocument CreateOpenApiDocument() }, [logoPath] = new OpenApiPathItem() { - Operations = new Dictionary + Operations = new Dictionary { { - OperationType.Put, new OpenApiOperation + HttpMethod.Put, new OpenApiOperation { OperationId = "applications.application.UpdateLogo", Summary = "Update media content for application in applications", @@ -413,10 +413,10 @@ public static OpenApiDocument CreateOpenApiDocument() }, [securityProfilesPath] = new OpenApiPathItem() { - Operations = new Dictionary + Operations = new Dictionary { { - OperationType.Get, new OpenApiOperation + HttpMethod.Get, new OpenApiOperation { OperationId = "security.ListHostSecurityProfiles", Summary = "Get hostSecurityProfiles from security", @@ -459,10 +459,10 @@ public static OpenApiDocument CreateOpenApiDocument() }, [communicationsCallsKeepAlivePath] = new OpenApiPathItem() { - Operations = new Dictionary + Operations = new Dictionary { { - OperationType.Post, new OpenApiOperation + HttpMethod.Post, new OpenApiOperation { OperationId = "communications.calls.call.keepAlive", Summary = "Invoke action keepAlive", @@ -507,10 +507,10 @@ public static OpenApiDocument CreateOpenApiDocument() }, [eventsDeltaPath] = new OpenApiPathItem() { - Operations = new Dictionary + Operations = new Dictionary { { - OperationType.Get, new OpenApiOperation + HttpMethod.Get, new OpenApiOperation { OperationId = "groups.group.events.event.calendar.events.delta", Summary = "Invoke function delta", @@ -594,10 +594,10 @@ public static OpenApiDocument CreateOpenApiDocument() }, [refPath] = new OpenApiPathItem() { - Operations = new Dictionary + Operations = new Dictionary { { - OperationType.Get, new OpenApiOperation + HttpMethod.Get, new OpenApiOperation { OperationId = "applications.GetRefCreatedOnBehalfOf", Summary = "Get ref of createdOnBehalfOf from applications" @@ -678,23 +678,23 @@ public static OpenApiDocument CreateOpenApiDocument() } } }; - document.Paths[getTeamsActivityByPeriodPath].Operations[OperationType.Get].Tags = new HashSet {new OpenApiTagReference("reports.Functions", document)}; - document.Paths[getTeamsActivityByDatePath].Operations[OperationType.Get].Tags = new HashSet {new OpenApiTagReference("reports.Functions", document)}; - document.Paths[usersPath].Operations[OperationType.Get].Tags = new HashSet {new OpenApiTagReference("users.user", document)}; - document.Paths[usersByIdPath].Operations[OperationType.Get].Tags = new HashSet {new OpenApiTagReference("users.user", document)}; - document.Paths[usersByIdPath].Operations[OperationType.Patch].Tags = new HashSet {new OpenApiTagReference("users.user", document)}; - document.Paths[messagesByIdPath].Operations[OperationType.Get].Tags = new HashSet {new OpenApiTagReference("users.message", document)}; - document.Paths[administrativeUnitRestorePath].Operations[OperationType.Post].Tags = new HashSet {new OpenApiTagReference("administrativeUnits.Actions", document)}; - document.Paths[logoPath].Operations[OperationType.Put].Tags = new HashSet {new OpenApiTagReference("applications.application", document)}; - document.Paths[securityProfilesPath].Operations[OperationType.Get].Tags = new HashSet {new OpenApiTagReference("security.hostSecurityProfile", document)}; - document.Paths[communicationsCallsKeepAlivePath].Operations[OperationType.Post].Tags = new HashSet {new OpenApiTagReference("communications.Actions", document)}; - document.Paths[eventsDeltaPath].Operations[OperationType.Get].Tags = new HashSet {new OpenApiTagReference("groups.Functions", document)}; - document.Paths[refPath].Operations[OperationType.Get].Tags = new HashSet {new OpenApiTagReference("applications.directoryObject", document)}; - ((OpenApiSchema)document.Paths[usersPath].Operations[OperationType.Get].Responses!["200"].Content[applicationJsonMediaType].Schema!.Properties["value"]).Items = new OpenApiSchemaReference("microsoft.graph.user", document); - document.Paths[usersByIdPath].Operations[OperationType.Get].Responses!["200"].Content[applicationJsonMediaType].Schema = new OpenApiSchemaReference("microsoft.graph.user", document); - document.Paths[messagesByIdPath].Operations[OperationType.Get].Responses!["200"].Content[applicationJsonMediaType].Schema = new OpenApiSchemaReference("microsoft.graph.message", document); - ((OpenApiSchema)document.Paths[securityProfilesPath].Operations[OperationType.Get].Responses!["200"].Content[applicationJsonMediaType].Schema!.Properties["value"]).Items = new OpenApiSchemaReference("microsoft.graph.networkInterface", document); - ((OpenApiSchema)document.Paths[eventsDeltaPath].Operations[OperationType.Get].Responses!["200"].Content[applicationJsonMediaType].Schema!.Properties["value"]).Items = new OpenApiSchemaReference("microsoft.graph.event", document); + document.Paths[getTeamsActivityByPeriodPath].Operations[HttpMethod.Get].Tags = new HashSet {new OpenApiTagReference("reports.Functions", document)}; + document.Paths[getTeamsActivityByDatePath].Operations[HttpMethod.Get].Tags = new HashSet {new OpenApiTagReference("reports.Functions", document)}; + document.Paths[usersPath].Operations[HttpMethod.Get].Tags = new HashSet {new OpenApiTagReference("users.user", document)}; + document.Paths[usersByIdPath].Operations[HttpMethod.Get].Tags = new HashSet {new OpenApiTagReference("users.user", document)}; + document.Paths[usersByIdPath].Operations[HttpMethod.Patch].Tags = new HashSet {new OpenApiTagReference("users.user", document)}; + document.Paths[messagesByIdPath].Operations[HttpMethod.Get].Tags = new HashSet {new OpenApiTagReference("users.message", document)}; + document.Paths[administrativeUnitRestorePath].Operations[HttpMethod.Post].Tags = new HashSet {new OpenApiTagReference("administrativeUnits.Actions", document)}; + document.Paths[logoPath].Operations[HttpMethod.Put].Tags = new HashSet {new OpenApiTagReference("applications.application", document)}; + document.Paths[securityProfilesPath].Operations[HttpMethod.Get].Tags = new HashSet {new OpenApiTagReference("security.hostSecurityProfile", document)}; + document.Paths[communicationsCallsKeepAlivePath].Operations[HttpMethod.Post].Tags = new HashSet {new OpenApiTagReference("communications.Actions", document)}; + document.Paths[eventsDeltaPath].Operations[HttpMethod.Get].Tags = new HashSet {new OpenApiTagReference("groups.Functions", document)}; + document.Paths[refPath].Operations[HttpMethod.Get].Tags = new HashSet {new OpenApiTagReference("applications.directoryObject", document)}; + ((OpenApiSchema)document.Paths[usersPath].Operations[HttpMethod.Get].Responses!["200"].Content[applicationJsonMediaType].Schema!.Properties["value"]).Items = new OpenApiSchemaReference("microsoft.graph.user", document); + document.Paths[usersByIdPath].Operations[HttpMethod.Get].Responses!["200"].Content[applicationJsonMediaType].Schema = new OpenApiSchemaReference("microsoft.graph.user", document); + document.Paths[messagesByIdPath].Operations[HttpMethod.Get].Responses!["200"].Content[applicationJsonMediaType].Schema = new OpenApiSchemaReference("microsoft.graph.message", document); + ((OpenApiSchema)document.Paths[securityProfilesPath].Operations[HttpMethod.Get].Responses!["200"].Content[applicationJsonMediaType].Schema!.Properties["value"]).Items = new OpenApiSchemaReference("microsoft.graph.networkInterface", document); + ((OpenApiSchema)document.Paths[eventsDeltaPath].Operations[HttpMethod.Get].Responses!["200"].Content[applicationJsonMediaType].Schema!.Properties["value"]).Items = new OpenApiSchemaReference("microsoft.graph.event", document); return document; } } diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs index be5921e54..f76e3311c 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Net.Http; using System.Threading; using System.Threading.Tasks; using FluentAssertions; @@ -143,7 +144,7 @@ public async Task ShouldParseProducesInAnyOrder() { Operations = { - [OperationType.Get] = new() + [HttpMethod.Get] = new() { Responses = { @@ -167,7 +168,7 @@ public async Task ShouldParseProducesInAnyOrder() } } }, - [OperationType.Post] = new() + [HttpMethod.Post] = new() { Responses = { @@ -189,7 +190,7 @@ public async Task ShouldParseProducesInAnyOrder() } } }, - [OperationType.Patch] = new() + [HttpMethod.Patch] = new() { Responses = { @@ -242,7 +243,7 @@ public async Task ShouldAssignSchemaToAllResponses() }; var errorSchema = new OpenApiSchemaReference("Error", result.Document); - var responses = result.Document.Paths["/items"].Operations[OperationType.Get].Responses; + var responses = result.Document.Paths["/items"].Operations[HttpMethod.Get].Responses; foreach (var response in responses) { var targetSchema = response.Key == "200" ? (IOpenApiSchema)successSchema : errorSchema; @@ -284,7 +285,7 @@ public async Task ParseDocumentWithDefaultContentTypeSettingShouldSucceed() settings.AddYamlReader(); var actual = await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, "docWithEmptyProduces.yaml"), settings); - var mediaType = actual.Document.Paths["/example"].Operations[OperationType.Get].Responses["200"].Content; + var mediaType = actual.Document.Paths["/example"].Operations[HttpMethod.Get].Responses["200"].Content; Assert.Contains("application/json", mediaType); } diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs index 00c4faaeb..cd62c27be 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.IO; +using System.Net.Http; using System.Text; using System.Text.Json.Nodes; using System.Threading.Tasks; @@ -523,9 +524,9 @@ public async Task SerializesBodyReferencesWorks() }; openApiDocument.Paths.Add("/users", new OpenApiPathItem { - Operations = new Dictionary + Operations = new Dictionary { - [OperationType.Post] = operation + [HttpMethod.Post] = operation } }); openApiDocument.AddComponent("UserRequest", new OpenApiRequestBody diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiPathItemTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiPathItemTests.cs index 412a74dde..b3ebdc3dc 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiPathItemTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiPathItemTests.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Net.Http; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Reader.ParseNodes; using Microsoft.OpenApi.Reader.V2; @@ -40,7 +41,7 @@ public class OpenApiPathItemTests ], Operations = { - [OperationType.Put] = new() + [HttpMethod.Put] = new() { Summary = "Puts a pet in the store with form data", Description = "", @@ -135,7 +136,7 @@ public class OpenApiPathItemTests } } }, - [OperationType.Post] = new() + [HttpMethod.Post] = new() { Summary = "Posts a pet in the store with form data", Description = "", @@ -274,8 +275,8 @@ public void ParsePathItemWithFormDataPathParameterShouldSucceed() // Assert // FormData parameters at in the path level are pushed into Operation request bodies. - Assert.True(pathItem.Operations[OperationType.Put].RequestBody != null); - Assert.True(pathItem.Operations[OperationType.Post].RequestBody != null); + Assert.True(pathItem.Operations[HttpMethod.Put].RequestBody != null); + Assert.True(pathItem.Operations[HttpMethod.Post].RequestBody != null); Assert.Equal(2, pathItem.Operations.Count(o => o.Value.RequestBody != null)); } [Fact] @@ -293,8 +294,8 @@ public void ParsePathItemBodyDataPathParameterShouldSucceed() // Assert // FormData parameters at in the path level are pushed into Operation request bodies. - Assert.True(pathItem.Operations[OperationType.Put].RequestBody != null); - Assert.True(pathItem.Operations[OperationType.Post].RequestBody != null); + Assert.True(pathItem.Operations[HttpMethod.Put].RequestBody != null); + Assert.True(pathItem.Operations[HttpMethod.Post].RequestBody != null); Assert.Equal(2, pathItem.Operations.Count(o => o.Value.RequestBody != null)); } } diff --git a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentTests.cs index 3f08158d4..62f7da105 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentTests.cs @@ -13,6 +13,7 @@ using VerifyXunit; using Microsoft.OpenApi.Models.Interfaces; using System; +using System.Net.Http; namespace Microsoft.OpenApi.Readers.Tests.V31Tests { @@ -112,9 +113,9 @@ public async Task ParseDocumentWithWebhooksShouldSucceed() { ["pets"] = new OpenApiPathItem { - Operations = new Dictionary + Operations = new Dictionary { - [OperationType.Get] = new OpenApiOperation + [HttpMethod.Get] = new OpenApiOperation { Description = "Returns all pets from the system that the user has access to", OperationId = "findPets", @@ -175,7 +176,7 @@ public async Task ParseDocumentWithWebhooksShouldSucceed() } } }, - [OperationType.Post] = new OpenApiOperation + [HttpMethod.Post] = new OpenApiOperation { RequestBody = new OpenApiRequestBody { @@ -302,9 +303,9 @@ public async Task ParseDocumentsWithReusablePathItemInWebhooksSucceeds() { ["pets"] = new OpenApiPathItem { - Operations = new Dictionary + Operations = new Dictionary { - [OperationType.Get] = new OpenApiOperation + [HttpMethod.Get] = new OpenApiOperation { Description = "Returns all pets from the system that the user has access to", OperationId = "findPets", @@ -365,7 +366,7 @@ public async Task ParseDocumentsWithReusablePathItemInWebhooksSucceeds() } } }, - [OperationType.Post] = new OpenApiOperation + [HttpMethod.Post] = new OpenApiOperation { RequestBody = new OpenApiRequestBody { @@ -441,7 +442,7 @@ public async Task ParseDocumentWithPatternPropertiesInSchemaWorks() { // Arrange and Act var result = await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, "docWithPatternPropertiesInSchema.yaml"), SettingsFixture.ReaderSettings); - var actualSchema = result.Document.Paths["/example"].Operations[OperationType.Get].Responses["200"].Content["application/json"].Schema; + var actualSchema = result.Document.Paths["/example"].Operations[HttpMethod.Get].Responses["200"].Content["application/json"].Schema; var expectedSchema = new OpenApiSchema { @@ -471,7 +472,7 @@ public async Task ParseDocumentWithPatternPropertiesInSchemaWorks() }; // Serialization - var mediaType = result.Document.Paths["/example"].Operations[OperationType.Get].Responses["200"].Content["application/json"]; + var mediaType = result.Document.Paths["/example"].Operations[HttpMethod.Get].Responses["200"].Content["application/json"]; var expectedMediaType = @"schema: patternProperties: @@ -499,9 +500,9 @@ public async Task ParseDocumentWithReferenceByIdGetsResolved() // Arrange and Act var result = await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, "docWithReferenceById.yaml"), SettingsFixture.ReaderSettings); - var responseSchema = result.Document.Paths["/resource"].Operations[OperationType.Get].Responses["200"].Content["application/json"].Schema; - var requestBodySchema = result.Document.Paths["/resource"].Operations[OperationType.Post].RequestBody.Content["application/json"].Schema; - var parameterSchema = result.Document.Paths["/resource"].Operations[OperationType.Get].Parameters[0].Schema; + var responseSchema = result.Document.Paths["/resource"].Operations[HttpMethod.Get].Responses["200"].Content["application/json"].Schema; + var requestBodySchema = result.Document.Paths["/resource"].Operations[HttpMethod.Post].RequestBody.Content["application/json"].Schema; + var parameterSchema = result.Document.Paths["/resource"].Operations[HttpMethod.Get].Parameters[0].Schema; // Assert Assert.Equal(JsonSchemaType.Object, responseSchema.Type); @@ -524,7 +525,7 @@ public async Task ExternalDocumentDereferenceToOpenApiDocumentUsingJsonPointerWo // Act var result = await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, "externalRefByJsonPointer.yaml"), settings); - var responseSchema = result.Document.Paths["/resource"].Operations[OperationType.Get].Responses["200"].Content["application/json"].Schema; + var responseSchema = result.Document.Paths["/resource"].Operations[HttpMethod.Get].Responses["200"].Content["application/json"].Schema; // Assert result.Document.Workspace.Contains("./externalResource.yaml"); @@ -548,7 +549,7 @@ public async Task ParseExternalDocumentDereferenceToOpenApiDocumentByIdWorks() var result = await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, "externalRefById.yaml"), settings); var doc2 = (await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, "externalResource.yaml"), SettingsFixture.ReaderSettings)).Document; - var requestBodySchema = result.Document.Paths["/resource"].Operations[OperationType.Get].Parameters[0].Schema; + var requestBodySchema = result.Document.Paths["/resource"].Operations[HttpMethod.Get].Parameters[0].Schema; result.Document.Workspace.RegisterComponents(doc2); // Assert diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiCallbackTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiCallbackTests.cs index cca7e002d..93b5677e7 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiCallbackTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiCallbackTests.cs @@ -3,6 +3,7 @@ using System.IO; using System.Linq; +using System.Net.Http; using System.Threading.Tasks; using Microsoft.OpenApi.Expressions; using Microsoft.OpenApi.Models; @@ -33,7 +34,7 @@ public async Task ParseBasicCallbackShouldSucceed() { Operations = { - [OperationType.Post] = + [HttpMethod.Post] = new OpenApiOperation { RequestBody = new OpenApiRequestBody @@ -67,7 +68,7 @@ public async Task ParseCallbackWithReferenceShouldSucceed() // Assert var path = result.Document.Paths.First().Value; - var subscribeOperation = path.Operations[OperationType.Post]; + var subscribeOperation = path.Operations[HttpMethod.Post]; var callback = subscribeOperation.Callbacks["simpleHook"]; @@ -81,7 +82,7 @@ public async Task ParseCallbackWithReferenceShouldSucceed() { [RuntimeExpression.Build("$request.body#/url")]= new OpenApiPathItem { Operations = { - [OperationType.Post] = new OpenApiOperation() + [HttpMethod.Post] = new OpenApiOperation() { RequestBody = new OpenApiRequestBody { @@ -117,7 +118,7 @@ public async Task ParseMultipleCallbacksWithReferenceShouldSucceed() // Assert var path = result.Document.Paths.First().Value; - var subscribeOperation = path.Operations[OperationType.Post]; + var subscribeOperation = path.Operations[HttpMethod.Post]; Assert.Equivalent( new OpenApiDiagnostic() { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }, result.Diagnostic); @@ -131,7 +132,7 @@ public async Task ParseMultipleCallbacksWithReferenceShouldSucceed() { [RuntimeExpression.Build("$request.body#/url")]= new OpenApiPathItem { Operations = { - [OperationType.Post] = new OpenApiOperation() + [HttpMethod.Post] = new OpenApiOperation() { RequestBody = new OpenApiRequestBody { @@ -166,7 +167,7 @@ public async Task ParseMultipleCallbacksWithReferenceShouldSucceed() { [RuntimeExpression.Build("/simplePath")]= new OpenApiPathItem { Operations = { - [OperationType.Post] = new OpenApiOperation() + [HttpMethod.Post] = new OpenApiOperation() { RequestBody = new OpenApiRequestBody { @@ -202,7 +203,7 @@ public async Task ParseMultipleCallbacksWithReferenceShouldSucceed() { [RuntimeExpression.Build(@"http://example.com?transactionId={$request.body#/id}&email={$request.body#/email}")] = new OpenApiPathItem { Operations = { - [OperationType.Post] = new OpenApiOperation() + [HttpMethod.Post] = new OpenApiOperation() { RequestBody = new OpenApiRequestBody { diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs index d46d33de9..9ad2aaaf9 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs @@ -6,6 +6,7 @@ using System.Globalization; using System.IO; using System.Linq; +using System.Net.Http; using System.Text; using System.Text.Json.Nodes; using System.Threading.Tasks; @@ -298,9 +299,9 @@ public async Task ParseStandardPetStoreDocumentShouldSucceed() { ["/pets"] = new OpenApiPathItem { - Operations = new Dictionary + Operations = new Dictionary { - [OperationType.Get] = new OpenApiOperation + [HttpMethod.Get] = new OpenApiOperation { Description = "Returns all pets from the system that the user has access to", OperationId = "findPets", @@ -383,7 +384,7 @@ public async Task ParseStandardPetStoreDocumentShouldSucceed() } } }, - [OperationType.Post] = new OpenApiOperation + [HttpMethod.Post] = new OpenApiOperation { Description = "Creates a new pet in the store. Duplicates are allowed", OperationId = "addPet", @@ -440,9 +441,9 @@ public async Task ParseStandardPetStoreDocumentShouldSucceed() }, ["/pets/{id}"] = new OpenApiPathItem { - Operations = new Dictionary + Operations = new Dictionary { - [OperationType.Get] = new OpenApiOperation + [HttpMethod.Get] = new OpenApiOperation { Description = "Returns a user based on a single ID, if the user does not have access to the pet", @@ -503,7 +504,7 @@ public async Task ParseStandardPetStoreDocumentShouldSucceed() } } }, - [OperationType.Delete] = new OpenApiOperation + [HttpMethod.Delete] = new OpenApiOperation { Description = "deletes a single pet based on the ID supplied", OperationId = "deletePet", @@ -717,9 +718,9 @@ public async Task ParseModifiedPetStoreDocumentWithTagAndSecurityShouldSucceed() { ["/pets"] = new OpenApiPathItem { - Operations = new Dictionary + Operations = new Dictionary { - [OperationType.Get] = new OpenApiOperation + [HttpMethod.Get] = new OpenApiOperation { Tags = new HashSet { @@ -807,7 +808,7 @@ public async Task ParseModifiedPetStoreDocumentWithTagAndSecurityShouldSucceed() } } }, - [OperationType.Post] = new OpenApiOperation + [HttpMethod.Post] = new OpenApiOperation { Tags = new HashSet { @@ -881,9 +882,9 @@ public async Task ParseModifiedPetStoreDocumentWithTagAndSecurityShouldSucceed() }, ["/pets/{id}"] = new OpenApiPathItem { - Operations = new Dictionary + Operations = new Dictionary { - [OperationType.Get] = new OpenApiOperation + [HttpMethod.Get] = new OpenApiOperation { Description = "Returns a user based on a single ID, if the user does not have access to the pet", @@ -944,7 +945,7 @@ public async Task ParseModifiedPetStoreDocumentWithTagAndSecurityShouldSucceed() } } }, - [OperationType.Delete] = new OpenApiOperation + [HttpMethod.Delete] = new OpenApiOperation { Description = "deletes a single pet based on the ID supplied", OperationId = "deletePet", @@ -1029,8 +1030,8 @@ public async Task ParseModifiedPetStoreDocumentWithTagAndSecurityShouldSucceed() actual.Document.Should().BeEquivalentTo(expected, options => options .IgnoringCyclicReferences() - .Excluding(x => x.Paths["/pets"].Operations[OperationType.Get].Tags) - .Excluding(x => x.Paths["/pets"].Operations[OperationType.Post].Tags) + .Excluding(ctx => ctx.Path.Contains("Paths[\"/pets\"].Operations[HttpMethod.Get].Tags")) + .Excluding(ctx => ctx.Path.Contains("Paths[\"/pets\"].Operations[HttpMethod.Post].Tags")) .Excluding(x => x.Workspace) .Excluding(y => y.BaseUri)); @@ -1140,7 +1141,7 @@ public async Task ParseDocumentWithJsonSchemaReferencesWorks() // Act var result = await OpenApiDocument.LoadAsync(stream, OpenApiConstants.Yaml, SettingsFixture.ReaderSettings); - var actualSchema = result.Document.Paths["/users/{userId}"].Operations[OperationType.Get].Responses["200"].Content["application/json"].Schema; + var actualSchema = result.Document.Paths["/users/{userId}"].Operations[HttpMethod.Get].Responses["200"].Content["application/json"].Schema; var expectedSchema = new OpenApiSchemaReference("User", result.Document); // Assert @@ -1219,7 +1220,7 @@ public async Task ParsesDoubleHopReferences() var (document, _) = await OpenApiDocument.LoadAsync(stream); Assert.NotNull(document); - var petReferenceInResponse = Assert.IsType(document.Paths["/pets"].Operations[OperationType.Get].Responses["200"].Content["application/json"].Schema); + var petReferenceInResponse = Assert.IsType(document.Paths["/pets"].Operations[HttpMethod.Get].Responses["200"].Content["application/json"].Schema); Assert.Equal("A reference to a pet reference", petReferenceInResponse.Description, StringComparer.OrdinalIgnoreCase); var petReference = Assert.IsType(petReferenceInResponse.Target); Assert.Equal("A reference to a pet", petReference.Description, StringComparer.OrdinalIgnoreCase); @@ -1268,9 +1269,9 @@ public async Task SerializesDoubleHopeReferences() document.AddComponent("PetReference", petSchemaReference); document.Paths.Add("/pets", new OpenApiPathItem { - Operations = new Dictionary + Operations = new Dictionary { - [OperationType.Get] = new OpenApiOperation + [HttpMethod.Get] = new OpenApiOperation { Summary = "Returns all pets", Responses = @@ -1334,9 +1335,9 @@ public async Task ParseDocWithRefsUsingProxyReferencesSucceeds() { ["/pets"] = new OpenApiPathItem { - Operations = new Dictionary + Operations = new Dictionary { - [OperationType.Get] = new OpenApiOperation + [HttpMethod.Get] = new OpenApiOperation { Summary = "Returns all pets", Parameters = @@ -1388,9 +1389,9 @@ public async Task ParseDocWithRefsUsingProxyReferencesSucceeds() // Act var doc = (await OpenApiDocument.LoadAsync(stream, settings: SettingsFixture.ReaderSettings)).Document; - var actualParam = doc.Paths["/pets"].Operations[OperationType.Get].Parameters[0]; + var actualParam = doc.Paths["/pets"].Operations[HttpMethod.Get].Parameters[0]; var outputDoc = (await doc.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi3_0)).MakeLineBreaksEnvironmentNeutral(); - var expectedParam = expected.Paths["/pets"].Operations[OperationType.Get].Parameters[0]; + var expectedParam = expected.Paths["/pets"].Operations[HttpMethod.Get].Parameters[0]; var expectedParamReference = Assert.IsType(expectedParam); var actualParamReference = Assert.IsType(actualParam); diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiOperationTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiOperationTests.cs index 661ca508d..1dd9ecce3 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiOperationTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiOperationTests.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Net.Http; using System.Text.Json.Nodes; using System.Threading.Tasks; using FluentAssertions; @@ -24,7 +25,7 @@ public async Task OperationWithSecurityRequirementShouldReferenceSecurityScheme( { var result = await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, "securedOperation.yaml"), SettingsFixture.ReaderSettings); - var securityScheme = result.Document.Paths["/"].Operations[OperationType.Get].Security[0].Keys.First(); + var securityScheme = result.Document.Paths["/"].Operations[HttpMethod.Get].Security[0].Keys.First(); Assert.Equivalent(result.Document.Components.SecuritySchemes.First().Value, securityScheme); } diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiParameterTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiParameterTests.cs index 33ebb0267..fd27c9416 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiParameterTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiParameterTests.cs @@ -11,6 +11,7 @@ using System.Threading.Tasks; using Microsoft.OpenApi.Models.Interfaces; using Microsoft.OpenApi.Models.References; +using System.Net.Http; namespace Microsoft.OpenApi.Readers.Tests.V3Tests { @@ -330,9 +331,9 @@ public void ParseParameterWithReferenceWorks() { ["/pets"] = new OpenApiPathItem { - Operations = new Dictionary + Operations = new Dictionary { - [OperationType.Get] = new OpenApiOperation + [HttpMethod.Get] = new OpenApiOperation { Description = "Returns all pets from the system that the user has access to", OperationId = "findPets", diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs index 7d57294c2..9205541cd 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs @@ -16,6 +16,7 @@ using FluentAssertions.Equivalency; using Microsoft.OpenApi.Models.References; using System.Threading.Tasks; +using System.Net.Http; namespace Microsoft.OpenApi.Readers.Tests.V3Tests { @@ -119,9 +120,9 @@ public void ParsePathFragmentShouldSucceed() new OpenApiPathItem { Summary = "externally referenced path item", - Operations = new Dictionary + Operations = new Dictionary { - [OperationType.Get] = new OpenApiOperation() + [HttpMethod.Get] = new OpenApiOperation() { Responses = new OpenApiResponses { diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.cs index fc232fa3a..2bc407557 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.cs @@ -3,6 +3,7 @@ using System.Globalization; using System.IO; +using System.Net.Http; using System.Threading.Tasks; using Microsoft.OpenApi.Expressions; using Microsoft.OpenApi.Models; @@ -25,7 +26,7 @@ public class OpenApiCallbackTests { Operations = { - [OperationType.Post] = + [HttpMethod.Post] = new() { RequestBody = new OpenApiRequestBody() @@ -65,7 +66,7 @@ public class OpenApiCallbackTests { Operations = { - [OperationType.Post] = + [HttpMethod.Post] = new() { RequestBody = new OpenApiRequestBody() diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiComponentsTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiComponentsTests.cs index 379dc0c4f..b0607f57e 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiComponentsTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiComponentsTests.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. using System.Collections.Generic; +using System.Net.Http; using System.Threading.Tasks; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; @@ -235,9 +236,9 @@ public class OpenApiComponentsTests { ["/pets"] = new OpenApiPathItem { - Operations = new Dictionary + Operations = new Dictionary { - [OperationType.Post] = new OpenApiOperation + [HttpMethod.Post] = new OpenApiOperation { RequestBody = new OpenApiRequestBody { diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs index b286839ac..76102456e 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.Globalization; using System.IO; +using System.Net.Http; using System.Threading.Tasks; using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Extensions; @@ -232,9 +233,9 @@ public class OpenApiDocumentTests { ["/pets"] = new OpenApiPathItem { - Operations = new Dictionary + Operations = new Dictionary { - [OperationType.Get] = new OpenApiOperation + [HttpMethod.Get] = new OpenApiOperation { Description = "Returns all pets from the system that the user has access to", OperationId = "findPets", @@ -317,7 +318,7 @@ public class OpenApiDocumentTests } } }, - [OperationType.Post] = new OpenApiOperation + [HttpMethod.Post] = new OpenApiOperation { Description = "Creates a new pet in the store. Duplicates are allowed", OperationId = "addPet", @@ -374,9 +375,9 @@ public class OpenApiDocumentTests }, ["/pets/{id}"] = new OpenApiPathItem { - Operations = new Dictionary + Operations = new Dictionary { - [OperationType.Get] = new OpenApiOperation + [HttpMethod.Get] = new OpenApiOperation { Description = "Returns a user based on a single ID, if the user does not have access to the pet", @@ -437,7 +438,7 @@ public class OpenApiDocumentTests } } }, - [OperationType.Delete] = new OpenApiOperation + [HttpMethod.Delete] = new OpenApiOperation { Description = "deletes a single pet based on the ID supplied", OperationId = "deletePet", @@ -608,9 +609,9 @@ public class OpenApiDocumentTests { ["/pets"] = new OpenApiPathItem { - Operations = new Dictionary + Operations = new Dictionary { - [OperationType.Get] = new OpenApiOperation + [HttpMethod.Get] = new OpenApiOperation { Description = "Returns all pets from the system that the user has access to", OperationId = "findPets", @@ -693,7 +694,7 @@ public class OpenApiDocumentTests } } }, - [OperationType.Post] = new OpenApiOperation + [HttpMethod.Post] = new OpenApiOperation { Description = "Creates a new pet in the store. Duplicates are allowed", OperationId = "addPet", @@ -750,9 +751,9 @@ public class OpenApiDocumentTests }, ["/pets/{id}"] = new OpenApiPathItem { - Operations = new Dictionary + Operations = new Dictionary { - [OperationType.Get] = new OpenApiOperation + [HttpMethod.Get] = new OpenApiOperation { Description = "Returns a user based on a single ID, if the user does not have access to the pet", @@ -813,7 +814,7 @@ public class OpenApiDocumentTests } } }, - [OperationType.Delete] = new OpenApiOperation + [HttpMethod.Delete] = new OpenApiOperation { Description = "deletes a single pet based on the ID supplied", OperationId = "deletePet", @@ -880,9 +881,9 @@ public class OpenApiDocumentTests { ["newPet"] = new OpenApiPathItem { - Operations = new Dictionary + Operations = new Dictionary { - [OperationType.Post] = new OpenApiOperation + [HttpMethod.Post] = new OpenApiOperation { RequestBody = new OpenApiRequestBody { @@ -956,9 +957,9 @@ public class OpenApiDocumentTests { ["/add/{operand1}/{operand2}"] = new OpenApiPathItem { - Operations = new Dictionary + Operations = new Dictionary { - [OperationType.Get] = new OpenApiOperation + [HttpMethod.Get] = new OpenApiOperation { OperationId = "addByOperand1AndByOperand2", Parameters = new List @@ -1067,9 +1068,9 @@ public class OpenApiDocumentTests { ["/pets"] = new OpenApiPathItem() { - Operations = new Dictionary + Operations = new Dictionary { - [OperationType.Get] = new() + [HttpMethod.Get] = new() { Description = "Returns all pets from the system that the user has access to", OperationId = "findPets", @@ -1152,7 +1153,7 @@ public class OpenApiDocumentTests } } }, - [OperationType.Post] = new() + [HttpMethod.Post] = new() { Description = "Creates a new pet in the store. Duplicates are allowed", OperationId = "addPet", @@ -1209,9 +1210,9 @@ public class OpenApiDocumentTests }, ["/pets/{id}"] = new OpenApiPathItem() { - Operations = new Dictionary + Operations = new Dictionary { - [OperationType.Get] = new() + [HttpMethod.Get] = new() { Description = "Returns a user based on a single ID, if the user does not have access to the pet", @@ -1272,7 +1273,7 @@ public class OpenApiDocumentTests } } }, - [OperationType.Delete] = new() + [HttpMethod.Delete] = new() { Description = "deletes a single pet based on the ID supplied", OperationId = "deletePet", @@ -1534,9 +1535,9 @@ public async Task SerializeDocumentWithReferenceButNoComponents() { ["/"] = new OpenApiPathItem { - Operations = new Dictionary + Operations = new Dictionary { - [OperationType.Get] = new OpenApiOperation + [HttpMethod.Get] = new OpenApiOperation { Responses = new OpenApiResponses { @@ -1555,7 +1556,7 @@ public async Task SerializeDocumentWithReferenceButNoComponents() } } }; - document.Paths["/"].Operations[OperationType.Get].Responses["200"].Content["application/json"].Schema = new OpenApiSchemaReference("test", document); + document.Paths["/"].Operations[HttpMethod.Get].Responses["200"].Content["application/json"].Schema = new OpenApiSchemaReference("test", document); // Act var actual = await document.SerializeAsync(OpenApiSpecVersion.OpenApi2_0, OpenApiFormat.Json); @@ -1707,9 +1708,9 @@ public async Task SerializeV2DocumentWithNonArraySchemaTypeDoesNotWriteOutCollec { ["/foo"] = new OpenApiPathItem { - Operations = new Dictionary + Operations = new Dictionary { - [OperationType.Get] = new OpenApiOperation + [HttpMethod.Get] = new OpenApiOperation { Parameters = [ @@ -1774,9 +1775,9 @@ public async Task SerializeV2DocumentWithStyleAsNullDoesNotWriteOutStyleValue() { ["/foo"] = new OpenApiPathItem { - Operations = new Dictionary + Operations = new Dictionary { - [OperationType.Get] = new OpenApiOperation + [HttpMethod.Get] = new OpenApiOperation { Parameters = [ @@ -1855,9 +1856,9 @@ public void SerializeExamplesDoesNotThrowNullReferenceException() { ["test"] = new OpenApiPathItem() { - Operations = new Dictionary() + Operations = new Dictionary() { - [OperationType.Post] = new OpenApiOperation + [HttpMethod.Post] = new OpenApiOperation { RequestBody = new OpenApiRequestBody() { @@ -1991,7 +1992,7 @@ public async Task SerializeV31DocumentWithRefsInWebhooksWorks() var writer = new OpenApiYamlWriter(stringWriter, new OpenApiWriterSettings { InlineLocalReferences = true }); var webhooks = doc.Webhooks["pets"].Operations; - webhooks[OperationType.Get].SerializeAsV31(writer); + webhooks[HttpMethod.Get].SerializeAsV31(writer); var actual = stringWriter.ToString(); Assert.Equal(expected.MakeLineBreaksEnvironmentNeutral(), actual.MakeLineBreaksEnvironmentNeutral()); } diff --git a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiCallbackReferenceTests.cs b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiCallbackReferenceTests.cs index b9f31f9e9..37cf0498a 100644 --- a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiCallbackReferenceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiCallbackReferenceTests.cs @@ -4,6 +4,7 @@ using System.Globalization; using System.IO; using System.Linq; +using System.Net.Http; using System.Threading.Tasks; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.References; @@ -148,13 +149,13 @@ public void CallbackReferenceResolutionWorks() Assert.NotEmpty(_externalCallbackReference.PathItems); Assert.Single(_externalCallbackReference.PathItems); Assert.Equal("{$request.body#/callbackUrl}", _externalCallbackReference.PathItems.First().Key.Expression); - Assert.Equal(OperationType.Post, _externalCallbackReference.PathItems.FirstOrDefault().Value.Operations.FirstOrDefault().Key);; + Assert.Equal(HttpMethod.Post, _externalCallbackReference.PathItems.FirstOrDefault().Value.Operations.FirstOrDefault().Key);; // Local reference resolution works Assert.NotEmpty(_localCallbackReference.PathItems); Assert.Single(_localCallbackReference.PathItems); Assert.Equal("{$request.body#/callbackUrl}", _localCallbackReference.PathItems.First().Key.Expression); - Assert.Equal(OperationType.Post, _localCallbackReference.PathItems.FirstOrDefault().Value.Operations.FirstOrDefault().Key); ; + Assert.Equal(HttpMethod.Post, _localCallbackReference.PathItems.FirstOrDefault().Value.Operations.FirstOrDefault().Key); ; } [Theory] diff --git a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiPathItemReferenceTests.cs b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiPathItemReferenceTests.cs index a6930cf8c..f46f6867d 100644 --- a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiPathItemReferenceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiPathItemReferenceTests.cs @@ -4,6 +4,7 @@ using System.Globalization; using System.IO; using System.Linq; +using System.Net.Http; using System.Threading.Tasks; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.References; @@ -101,13 +102,13 @@ public OpenApiPathItemReferenceTests() public void PathItemReferenceResolutionWorks() { // Assert - Assert.Equal([OperationType.Get, OperationType.Post, OperationType.Delete], + Assert.Equal([HttpMethod.Get, HttpMethod.Post, HttpMethod.Delete], _localPathItemReference.Operations.Select(o => o.Key)); Assert.Equal(3, _localPathItemReference.Operations.Count); Assert.Equal("Local reference: User path item description", _localPathItemReference.Description); Assert.Equal("Local reference: User path item summary", _localPathItemReference.Summary); - Assert.Equal([OperationType.Get, OperationType.Post, OperationType.Delete], + Assert.Equal([HttpMethod.Get, HttpMethod.Post, HttpMethod.Delete], _externalPathItemReference.Operations.Select(o => o.Key)); Assert.Equal("External reference: User path item description", _externalPathItemReference.Description); Assert.Equal("External reference: User path item summary", _externalPathItemReference.Summary); diff --git a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiTagReferenceTest.cs b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiTagReferenceTest.cs index 3fdd43d4b..e00927989 100644 --- a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiTagReferenceTest.cs +++ b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiTagReferenceTest.cs @@ -4,6 +4,7 @@ using System; using System.Globalization; using System.IO; +using System.Net.Http; using System.Threading.Tasks; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.References; @@ -79,7 +80,7 @@ public void TagReferenceResolutionWorks() Assert.Equal("user", _openApiTagReference.Name); Assert.Equal("Operations about users.", _openApiTagReference.Description); Assert.True(_openApiTagReference2.UnresolvedReference);// the target is null - var operationTags = _openApiDocument.Paths["/users/{userId}"].Operations[OperationType.Get].Tags; + var operationTags = _openApiDocument.Paths["/users/{userId}"].Operations[HttpMethod.Get].Tags; Assert.Null(operationTags); // the operation tags are not loaded due to the invalid syntax at the operation level(should be a list of strings) } diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index 74afafa5a..13fdf06fe 100644 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -390,7 +390,7 @@ namespace Microsoft.OpenApi.Models.Interfaces } public interface IOpenApiPathItem : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiSummarizedElement { - System.Collections.Generic.IDictionary Operations { get; } + System.Collections.Generic.IDictionary Operations { get; } System.Collections.Generic.IList Parameters { get; } System.Collections.Generic.IList Servers { get; } } @@ -945,11 +945,11 @@ namespace Microsoft.OpenApi.Models public OpenApiPathItem() { } public string Description { get; set; } public System.Collections.Generic.IDictionary Extensions { get; set; } - public System.Collections.Generic.IDictionary Operations { get; set; } + public System.Collections.Generic.IDictionary Operations { get; set; } public System.Collections.Generic.IList Parameters { get; set; } public System.Collections.Generic.IList Servers { get; set; } public string Summary { get; set; } - public void AddOperation(Microsoft.OpenApi.Models.OperationType operationType, Microsoft.OpenApi.Models.OpenApiOperation operation) { } + public void AddOperation(System.Net.Http.HttpMethod operationType, Microsoft.OpenApi.Models.OpenApiOperation operation) { } public Microsoft.OpenApi.Models.Interfaces.IOpenApiPathItem CreateShallowCopy() { } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -1144,25 +1144,6 @@ namespace Microsoft.OpenApi.Models public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } } - public enum OperationType - { - [Microsoft.OpenApi.Attributes.Display("get")] - Get = 0, - [Microsoft.OpenApi.Attributes.Display("put")] - Put = 1, - [Microsoft.OpenApi.Attributes.Display("post")] - Post = 2, - [Microsoft.OpenApi.Attributes.Display("delete")] - Delete = 3, - [Microsoft.OpenApi.Attributes.Display("options")] - Options = 4, - [Microsoft.OpenApi.Attributes.Display("head")] - Head = 5, - [Microsoft.OpenApi.Attributes.Display("patch")] - Patch = 6, - [Microsoft.OpenApi.Attributes.Display("trace")] - Trace = 7, - } public enum ParameterLocation { [Microsoft.OpenApi.Attributes.Display("query")] @@ -1331,7 +1312,7 @@ namespace Microsoft.OpenApi.Models.References public OpenApiPathItemReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument hostDocument = null, string externalResource = null) { } public string Description { get; set; } public System.Collections.Generic.IDictionary Extensions { get; } - public System.Collections.Generic.IDictionary Operations { get; } + public System.Collections.Generic.IDictionary Operations { get; } public System.Collections.Generic.IList Parameters { get; } public System.Collections.Generic.IList Servers { get; } public string Summary { get; set; } @@ -1561,7 +1542,7 @@ namespace Microsoft.OpenApi.Services public string Extension { get; } public string Header { get; } public string Link { get; set; } - public Microsoft.OpenApi.Models.OperationType? Operation { get; set; } + public System.Net.Http.HttpMethod Operation { get; set; } public string Path { get; set; } public string Response { get; set; } public string ServerVariable { get; } @@ -1581,9 +1562,9 @@ namespace Microsoft.OpenApi.Services } public static class OpenApiFilterService { - public static Microsoft.OpenApi.Models.OpenApiDocument CreateFilteredDocument(Microsoft.OpenApi.Models.OpenApiDocument source, System.Func predicate) { } + public static Microsoft.OpenApi.Models.OpenApiDocument CreateFilteredDocument(Microsoft.OpenApi.Models.OpenApiDocument source, System.Func predicate) { } public static Microsoft.OpenApi.Services.OpenApiUrlTreeNode CreateOpenApiUrlTreeNode(System.Collections.Generic.Dictionary sources) { } - public static System.Func CreatePredicate(string operationIds = null, string tags = null, System.Collections.Generic.Dictionary> requestUrls = null, Microsoft.OpenApi.Models.OpenApiDocument source = null) { } + public static System.Func CreatePredicate(string operationIds = null, string tags = null, System.Collections.Generic.Dictionary> requestUrls = null, Microsoft.OpenApi.Models.OpenApiDocument source = null) { } } public class OpenApiReferenceError : Microsoft.OpenApi.Models.OpenApiError { @@ -1645,7 +1626,7 @@ namespace Microsoft.OpenApi.Services public virtual void Visit(Microsoft.OpenApi.Models.OpenApiServerVariable serverVariable) { } public virtual void Visit(Microsoft.OpenApi.Models.OpenApiTag tag) { } public virtual void Visit(Microsoft.OpenApi.Models.References.OpenApiTagReference tag) { } - public virtual void Visit(System.Collections.Generic.IDictionary operations) { } + public virtual void Visit(System.Collections.Generic.IDictionary operations) { } public virtual void Visit(System.Collections.Generic.IDictionary callbacks) { } public virtual void Visit(System.Collections.Generic.IDictionary examples) { } public virtual void Visit(System.Collections.Generic.IDictionary headers) { } @@ -1683,7 +1664,7 @@ namespace Microsoft.OpenApi.Services } public class OperationSearch : Microsoft.OpenApi.Services.OpenApiVisitorBase { - public OperationSearch(System.Func predicate) { } + public OperationSearch(System.Func predicate) { } public System.Collections.Generic.IList SearchResults { get; } public override void Visit(Microsoft.OpenApi.Models.Interfaces.IOpenApiPathItem pathItem) { } public override void Visit(System.Collections.Generic.IList parameters) { } @@ -1743,7 +1724,7 @@ namespace Microsoft.OpenApi.Validations public override void Visit(Microsoft.OpenApi.Models.OpenApiServer server) { } public override void Visit(Microsoft.OpenApi.Models.OpenApiServerVariable serverVariable) { } public override void Visit(Microsoft.OpenApi.Models.OpenApiTag tag) { } - public override void Visit(System.Collections.Generic.IDictionary operations) { } + public override void Visit(System.Collections.Generic.IDictionary operations) { } public override void Visit(System.Collections.Generic.IDictionary callbacks) { } public override void Visit(System.Collections.Generic.IDictionary examples) { } public override void Visit(System.Collections.Generic.IDictionary headers) { } diff --git a/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.cs b/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.cs index 33296cfed6..3292a6990 100644 --- a/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.cs +++ b/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.cs @@ -1,9 +1,10 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System; using System.Collections.Generic; using System.IO; +using System.Net.Http; using System.Threading.Tasks; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Services; @@ -20,24 +21,24 @@ public class OpenApiUrlTreeNodeTests { ["/"] = new OpenApiPathItem() { - Operations = new Dictionary + Operations = new Dictionary { - [OperationType.Get] = new(), + [HttpMethod.Get] = new(), } }, ["/houses"] = new OpenApiPathItem() { - Operations = new Dictionary + Operations = new Dictionary { - [OperationType.Get] = new(), - [OperationType.Post] = new() + [HttpMethod.Get] = new(), + [HttpMethod.Post] = new() } }, ["/cars"] = new OpenApiPathItem() { - Operations = new Dictionary + Operations = new Dictionary { - [OperationType.Post] = new() + [HttpMethod.Post] = new() } } } @@ -148,10 +149,10 @@ public void AttachPathWorks() var pathItem1 = new OpenApiPathItem { - Operations = new Dictionary + Operations = new Dictionary { { - OperationType.Get, new OpenApiOperation + HttpMethod.Get, new OpenApiOperation { OperationId = "motorcycles.ListMotorcycle", Responses = new() @@ -173,10 +174,10 @@ public void AttachPathWorks() var pathItem2 = new OpenApiPathItem { - Operations = new Dictionary + Operations = new Dictionary { { - OperationType.Get, new OpenApiOperation + HttpMethod.Get, new OpenApiOperation { OperationId = "computers.ListComputer", Responses = new() @@ -240,10 +241,10 @@ public void HasOperationsWorks() ["/houses"] = new OpenApiPathItem(), ["/cars/{car-id}"] = new OpenApiPathItem() { - Operations = new Dictionary + Operations = new Dictionary { { - OperationType.Get, new OpenApiOperation + HttpMethod.Get, new OpenApiOperation { OperationId = "cars.GetCar", Responses = new() @@ -268,10 +269,10 @@ public void HasOperationsWorks() { ["/cars/{car-id}"] = new OpenApiPathItem() { - Operations = new Dictionary + Operations = new Dictionary { { - OperationType.Get, new OpenApiOperation + HttpMethod.Get, new OpenApiOperation { OperationId = "cars.GetCar", Responses = new() @@ -286,7 +287,7 @@ public void HasOperationsWorks() } }, { - OperationType.Put, new OpenApiOperation + HttpMethod.Put, new OpenApiOperation { OperationId = "cars.UpdateCar", Responses = new() diff --git a/test/Microsoft.OpenApi.Tests/Services/OpenApiValidatorTests.cs b/test/Microsoft.OpenApi.Tests/Services/OpenApiValidatorTests.cs index d11786d5b..90f88e378 100644 --- a/test/Microsoft.OpenApi.Tests/Services/OpenApiValidatorTests.cs +++ b/test/Microsoft.OpenApi.Tests/Services/OpenApiValidatorTests.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Net.Http; using System.Text.Json; using System.Text.Json.Nodes; using Microsoft.OpenApi.Any; @@ -38,7 +39,7 @@ public void ResponseMustHaveADescription() { Operations = { - [OperationType.Get] = new() + [HttpMethod.Get] = new() { Responses = { diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiReferenceValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiReferenceValidationTests.cs index b9a73da40..1828ca470 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiReferenceValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiReferenceValidationTests.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Net.Http; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.Interfaces; @@ -38,9 +39,9 @@ public void ReferencedSchemaShouldOnlyBeValidatedOnce() { ["/"] = new OpenApiPathItem() { - Operations = new Dictionary + Operations = new Dictionary { - [OperationType.Get] = new() + [HttpMethod.Get] = new() { Responses = new() { @@ -92,9 +93,9 @@ public void UnresolvedSchemaReferencedShouldNotBeValidated() { ["/"] = new OpenApiPathItem() { - Operations = new Dictionary + Operations = new Dictionary { - [OperationType.Get] = new() + [HttpMethod.Get] = new() { Responses = new() { diff --git a/test/Microsoft.OpenApi.Tests/Visitors/InheritanceTests.cs b/test/Microsoft.OpenApi.Tests/Visitors/InheritanceTests.cs index 44febe633..ee7252d42 100644 --- a/test/Microsoft.OpenApi.Tests/Visitors/InheritanceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Visitors/InheritanceTests.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Linq; +using System.Net.Http; using System.Runtime.CompilerServices; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; @@ -28,7 +29,7 @@ public void ExpectedVirtualsInvolved() visitor.Visit(default(OpenApiPaths)); visitor.Visit(default(IOpenApiPathItem)); visitor.Visit(default(OpenApiServerVariable)); - visitor.Visit(default(IDictionary)); + visitor.Visit(default(IDictionary)); visitor.Visit(default(OpenApiOperation)); visitor.Visit(default(IList)); visitor.Visit(default(IOpenApiParameter)); @@ -142,7 +143,7 @@ public override void Visit(OpenApiServerVariable serverVariable) base.Visit(serverVariable); } - public override void Visit(IDictionary operations) + public override void Visit(IDictionary operations) { EncodeCall(); base.Visit(operations); diff --git a/test/Microsoft.OpenApi.Tests/Walkers/WalkerLocationTests.cs b/test/Microsoft.OpenApi.Tests/Walkers/WalkerLocationTests.cs index a2f66e0c8..feee331af 100644 --- a/test/Microsoft.OpenApi.Tests/Walkers/WalkerLocationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Walkers/WalkerLocationTests.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Net.Http; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.Interfaces; @@ -68,9 +69,9 @@ public void LocatePathOperationContentSchema() var doc = new OpenApiDocument(); doc.Paths.Add("/test", new OpenApiPathItem() { - Operations = new Dictionary + Operations = new Dictionary { - [OperationType.Get] = new() + [HttpMethod.Get] = new() { Responses = new() { @@ -110,7 +111,7 @@ public void LocatePathOperationContentSchema() }, locator.Locations); - Assert.Equivalent(new List { "/test", "Get", "200", "application/json" }, locator.Keys); + Assert.Equivalent(new List { "/test", "GET", "200", "application/json" }, locator.Keys); } [Fact] @@ -177,9 +178,9 @@ public void LocateReferences() { ["/"] = new OpenApiPathItem() { - Operations = new Dictionary + Operations = new Dictionary { - [OperationType.Get] = new() + [HttpMethod.Get] = new() { Responses = new() { diff --git a/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiWorkspaceTests.cs b/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiWorkspaceTests.cs index 8c5478cf7..02c1cf07c 100644 --- a/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiWorkspaceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiWorkspaceTests.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Net.Http; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.References; @@ -27,9 +28,9 @@ public void OpenApiWorkspacesCanAddComponentsFromAnotherDocument() { ["/"] = new OpenApiPathItem() { - Operations = new Dictionary() + Operations = new Dictionary() { - [OperationType.Get] = new OpenApiOperation() + [HttpMethod.Get] = new OpenApiOperation() { Responses = new OpenApiResponses() { @@ -156,7 +157,7 @@ public static OpenApiDocument CreatePathItem(this OpenApiDocument document, stri return document; } - public static OpenApiPathItem CreateOperation(this OpenApiPathItem parent, OperationType opType, Action config) + public static OpenApiPathItem CreateOperation(this OpenApiPathItem parent, HttpMethod opType, Action config) { var child = new OpenApiOperation(); config(child); diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiYamlWriterTests.cs b/test/Microsoft.OpenApi.Tests/Writers/OpenApiYamlWriterTests.cs index 669f4cb13..1f4d45e81 100644 --- a/test/Microsoft.OpenApi.Tests/Writers/OpenApiYamlWriterTests.cs +++ b/test/Microsoft.OpenApi.Tests/Writers/OpenApiYamlWriterTests.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Globalization; using System.IO; +using System.Net.Http; using System.Threading.Tasks; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.References; @@ -390,7 +391,7 @@ public void WriteInlineSchema() // Act doc.SerializeAsV3(writer); - var mediaType = doc.Paths["/"].Operations[OperationType.Get].Responses["200"].Content["application/json"]; + var mediaType = doc.Paths["/"].Operations[HttpMethod.Get].Responses["200"].Content["application/json"]; var actual = outputString.GetStringBuilder().ToString(); // Assert @@ -456,7 +457,7 @@ private static OpenApiDocument CreateDocWithSimpleSchemaToInline() ["/"] = new OpenApiPathItem() { Operations = { - [OperationType.Get] = new() + [HttpMethod.Get] = new() { Responses = { ["200"] = new OpenApiResponse() From 0fee1a175dbb5ef92ba4aee45ea0cedae479c835 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Wed, 12 Mar 2025 08:10:37 -0400 Subject: [PATCH 014/984] docs: updates workbench screenshot to remove offending number Signed-off-by: Vincent Biret --- docs/images/workbench.png | Bin 72107 -> 38336 bytes src/Microsoft.OpenApi.Workbench/MainModel.cs | 8 ++++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/images/workbench.png b/docs/images/workbench.png index 718c44954c11b8913d443c0677e6c8ae86e46251..898fe9b5be1532295216e48f61856c9a27ef5d96 100644 GIT binary patch literal 38336 zcmcG#cQl+|^fx+s5To~Df(W7q(TSc)^yt0!-i;caG$av33(&{wO&*LfQ?6dc0fA(jeiF>K8Mn=L!0s?`^o;+680)glvFR~n@Da*HH9xWEowbWva5aL0)#HWPH|NVPOhnCgEV z74xGf^}Q@z^yxI<2(7YL6W5Q92u#qFlkU;OablOA29cE#MuC;6UweylTv^NCzx7jS z9sxzExw?iHZX>3SkAAL=W(5s5p}u|k9k6sPhmuH^zw$r*L9G!rw*A8fh6-(*n_cm3 zSed8@Ad4*m7q^8udQ6kr>wZU~#IBlj=Ipw}&fR=@hMLN)^qR7ocjjoOzW?zjOU^A$ zs?$DiWp*l@4&KRax=0nwS9k%*xc`c7NpWBikrm3M0g(vf%9072L+*7|gr4$ZR>)yt zYlCi~HGx+I3c-K#u(3(%g>9^qx^Tq5Z-={qKD;PY9afvCVK}!YTZe`2xOG=fFLk%5 zg^an(H1)NUd#7nzRsH>JKdXHjqlo64H?n3smm;hNt|Uqp1+xN4#1}n94nBR3Sj#TQ ze7tbWMq~HT6q>SUCZ^({Ditiq4xc92J!DAQ^QQMDmcqj=2UfaGubbz%a~_&Bh}v@- zz0^Io5}#E4em?G2?Rrk?p!mLz%cKcaVFUXjw)T1WiWwq;uDP$q6#Mz*K~QY}>eTV9 zB{pad`+d4WkO%#1!lG)Z<6upv@pbcV`h@Ya`6Q2I;k$_9rzs1sF8^(esZ#qq6SQRg zEFrgjzs-;T60eN7!+(cIA{4tvn!2c&JMrrxP7u|md0-ah)8RSyz1Y)Dq|6lA(Qu^E zYue5ydV~lNF3-!c0$%WXmb+>eH%6u0ED+~-eEH~C?w_EkfAW7myGON!+3VK8U_~~j z6XUb$$^&Ce=!OA-QL5DpjS>btB6dRx@PJeMPTaPAfK$)rSBKshyXfH9w39Z&RJtSb zVR_avPhIU))+H=3u9&5{1gF`*o0QCbo2lZtmN!0J!H?}9i7tQe)B&JCX z3x?Jzo~B;mOqKiz(sv6wmc8215_9+8vXhS#ZF2<2MFrAqd#l#d%q<)~i-3-WE8iwBp|5rPdD?k(O~2*!)~w`pp&pfxzjTR2qT zZ}y0EJOHEX(9ZJVDZ<1dNdNNqPP^QLh;*~inRa53`wvRBWsbRqwP$7w)ozAbg_!~O z+K~veF6rUpIdL3NsHYnh^s(1`i>9i7LpK*Em8(~846Gc3vQKouf6h1@u9!K^u_s1&&7-2*41Q>hi&zUhRp z`|JF9xK`LBSRJbHPls6U14!Cb@b@(OvfE`BbApXhaypa4|18b);eEwxfw6iq(b(*j zT@H@3?aQ&V3G83~3hby^fXqdWC}0N5iu%9T(+zj;p*{Q6_5^(o^LO!X6mNN_e#bu> z^tW$1WDwKPa~lcBt`I85P8jvO<}7;?8;i-thDFANrYOaL@f;nL>ko?lRD1fuwh4og zB2%lV;db-(jSWv5>60?#-*CLM;TD*)AR*}3*!AjL1gd>=0Xe90wNZ_-*x^Faq%K^p zDQg-yUW9&uDNtk>m*-yEQ}WIGky0AGl5Sa-YG3cSKR0OXpzcWgK0&u3a{6yTaP9AV zjb38rhaW;*LdP=hC#&)m_+@RzcpeXOc12Q(a*Hn+dx++0>f*)Flegi6{0B=?Uau7? zoxyYDR~rOnlFVeW%pv6b)LIkRus%!=sl>qqth)B)qOm}XlN|p_jvAErK9m`Yb9H_nT-dR94goT!;`iHpnEy$~X>?r((=%byJH`YNu za%2kka}|aaJ}4EZ>~C|dLYTS9I)0D#pQA75P)e|pdNlXs!+ZeH)Df!g|d49U+g0c<*Oi{F0TJ+QsY7w`D~CUiXyPJrQ369+LJ# zrP{2ej>XAPrv~xs+FiL?wSpKo@j-2fwjZT6<~!%|IkR#T^`r0Xd$O$yd?g%w9D3{m z6!_89cMTnnFV!9_T_g-J$?z$UgarcYa>xY<*kdb|-=LU;hTKwPJKK(_ThZetZjz`G6@X=Ea3(GT;?LBo{~Zm zX*l6Lu%mll{?WVLzhCkfc7^WP2Mp3ax-AN8@ck%%>_#c`=Ci=gN!DS!mHWnaA#DNC z0_H^z=G< zBTnbN^Z`DR4e>`B1{c3ORDK6$7z-FzUBWlE;s;LeiOBYk%y|)Coql$D)^Bv0#jt6I zPpYTyjIA`d0$iu$4D~r(_3B01T!S$qCBKx@a>MMEL3#bI0nLk6huchg+4NV3ea)t2 z;!DFr!MlPiPJvoYlH_GC^_SiMjtW{{3LB2NkB`Cx@WGQPJpyps2~`%X{VX{^(k}b* z;k=AzUK>N@d|kzlTla@L?$|GKiksF21C#I=Eaa^53ITp!A0;4#XRC)hiheLORT6Uc z&c_69h_|kgG4HE<<06N2UZNJA1OAs5}*xrRSj1DU^MoJl@(p?uvML~h_z0MB$JAzTrkT({zCJze+9avfrVJ?Sf&7$7RY~yU~Yl)@SH}icZ)((j>@3X)$y$;OBZ49|>;aTf)5G zyFt>xeOe!$o&Yg8c*)BMKyQ1%z@UnPUdbXgXv3H^PyGpn!a)3`S^6caVC1)?`*N&3 zE8Q|QS@yJ%aWI&k4|WVQvtK{^iQJdC+^g~U{hG|iw4$4b#jRJZ-mO93NUOMbH4p1; z^JK(aC?W=S)(5M0b9_3HnnxWcp*~&NW$G*iSnGxktixlDsyW@Zw+pj-4YF#EW~bWg z?XjwvK!kmM){wKFv&xn5S@%GG!*VT2 zmjO;#Bl}v};_tIYi@)dg?W?m)>W+(5GVMYPrFxgj{@jd+H`ARgAwc$eL_WZX;^^?f zDx11%cU}JD!E{YYe-iB95)N7D7JFZ&E*?Hb&xsj!{JHW~y$nQ|859$OpCyIE+3k@P zX4^|jHT#+>sf&(EB5na?$!7d@LveZyj@j8Z=oxOmY9GVjPQ|;g#L5fGA3psp=h^MD_&Qr4d&bJ45xcl(vf1gz$)gV za0TV~le+tdZ*F*ArX!v1xOoStR#-}$4Jp=Brp_`J{mBfQ_Lf*{-vO3OHoSD}zvu{V z!X9Nw2C{j}bpV7~7N+R~_PjOs0-t`&Ei65QevDY6*%jHMP*B>!q z_dC~@~YEYY>}`SE>Vd09X7cB2dOB<{+Eii1++Ln z`w!2pKSq*lAPj!CKaBlO^Wz~A#IlW8P4~}xzCOQ?eWlg%*E2|v!D5cjhWy$itslgd z88uj%n}eX(vp$be6?(S!zs#+z@rPxO6WeCvD?e8xeb(l12Zho6$PCLZekr2)2vYC; z)5bdqwdJ7V;jf(INJ6!&>Ms>pG?iel8qGvD>jwh;G>Mi3>slp5-HHharu}rKd22!= z3@}=eO>bXcmB*Uu-gFfnSC&8fWQAFZ&+eoJ{54tQUiARQE&Q+C@&D(&YRk(iI>c}? z(7~OHHV5m$_5cQtnq%mXM>GsCes`?7X0E+ts|SIsYaAXOJcvwuC>%ZBE*YY(Oru*& z1Y| zyvGKPb@6li3dP(${hgB6o>W`8v9VEU0Vf1?PEUUf5efbGJ{tr|mby{QJ>%+8lF<}{z|nM~4r zpc`{{uNPg`G;q7%v)^Ab!46Dyo4tY2;FRj1S5a~CEa~q1uq_5P@=Yqh!AF@+G7-T< z^d{bv51psO1cO&d&vx`X3~NK?>RlSIE_RPF$HQxBMy}!9@hWraB7nter~r$J58uR6 z?s>l=lD3*i?#sDfCBy4o=G^z|rf@;5fm>`}0(ZXG z&-R20`w}dkrO5Xp_-vY(@%;Oy!1f(7m)U32W^I(%Gpk)zkf%8NGPic}A1Rgn3G=pk z$DO8!O8=;t-OpJB89G*|nMq&>MM==#!=&ZWv|+f>QBR1V!9y5cSKhu4=&pRYU#JHZ zOrNerdK1pMHjiLBK`a`&#zIJ+B1ehc(wf5rGYsyh=Y(p|5Yh5Bq@fJv5dQJgr>^VZ zTT7M(Ysg=U9&}(sofn!XOxu1k3!L3rMAvx8I3uxMkM9n3+SR)df@Cg_i6O0LR5G4} ztkW%56{qbu^31SC?k!N*{Ivej@-Mf_)XBa;m(=kfmjcf-)k9p&!QAjJ48gU6&2Ag% z4uiB)%FvFIj!9U{VK$zfP0Xe6foWt+_Yh=oR_T%M&uYt^YFU79kIn*Se0Z0NI58z< zEt;OBZ5nWEN^+S)Q2SAm+an5mh=+2Lz|?Cmp~D98f=}PQJh9_pVqlVLO(oBrvBB!y-Xpe1zzO9ay z!<@rt3BpGQ%+OwWi9UD41j{S814Q2``BFr%vZ}@Mid*F|Z-DaOkjg}r5nQJe!57y~ z?N61I%~T>QorJJlo&_rPOCJ*2_xcy{;4)D5j$FvKm zEcZWrr&gE1$>mISoPlt8A5MPM0%MPK_HwzI{m)gD?R99`>MQ*;Z z*&YSO3dB@7!Q#nHeQ;_US2jONFetm%kam%m!i!`*JGZy0Qk}wMpcPjOUAeN%qy0|2 z8-1KmMmXnY$SBn%ZFqr(3wzj;L5EvmuG>^|`$29AAo&M%?sNo}!q@9cus_AL;5|eow&tTJ&<_b}of* zslIni;oyg&=b}lOo^F^h@n`WB@*<{awMcJdF1N);lYQ%gqz!5fig z0>qE(Ekv>OT)^ZU8FwK>`$q>e&P*$focyyaz2%iQWIS#(cq%Lyq1C{YrF|r5#pJ?j zb-_KT6wP^OhXd?lN%B2peTwatDl_?=jZNiNr)8zHGR%j9v23N)N%$7|j%F0^tA{4U zTTJY{&&XV+rO7Ke^P6|uDx|a-g*0YIdRw-{x5-fh)??Sa>o@Ib3DC&c0}6QJ2uqS z;D)V|!?k$ZLR4ipr}<3^17%UoqAs8(_;1bA=3UAE3OsYv((6^1Ow2k@#I>$@499CQ zLW>Ct%%OxPMEWdp)~Om+5B0N!v`ch!qc8qWoiq-Tu?b7c^l+p((hKMpf-oCr&x}N^iwF z<;-{{u6pC0J8Hg|Oe16l0B7j-Um*;Ab_K9dGW6Ma6@wb>qkzS$=&`$>*=2V9+R3d_kQUxP)u zX&?`f%|JlzzCL{a{=NUkCp-5UoAi~`ir|8_o%k*%W0oli=$Ex?)+eg5wzf9i=)vK; zHyuu`Aw#)4Rngb%vwNMJjeTcqZsFs;r0FqrQCSfyPj>o3{vQuKJ_I=1+O$?OTRxcMrW;;=zIIHAjdchpHMGG0(e-Uni2FQ`)Y;q|`$uefj^nU+Dim!BD9* zwGwOXok;qRF3JD|;hIB%!m6r-(YBbsT=F;|NXW_P$Bc{`H&e>esaIqb9zIq#oK}=v zuVybj-vOY=hM$>-h{~gGzbddsD2Z&KI>Yhtsy({g)eA5RbP<; zzja5qqT8d7CB|j0er49Ff&e6QGNL4LIrLw%agHdf?4IWs~2<{ zv9=hCYU&98l^co?nfBXE@py`8^1l@6=ytkV=P4>CIZYXx_8qX{-anR)952*}hM&5f zEj8$c9*437kwcRC8;1kpLbMG46XcgW8T&mD*guy#;NJNG?cPg4n!}d}mZd~vtfIK; zoPv)uF;1)R{(!MLjPveUVN>^Xi*^$HPt2$r^R2nyY`=d_t!5xs9~k;3`HKmhZ*jMy z)>gBw!rK~FhY`DqbIo|u=vA(xFU5+wx-v&Ah?T^YD~kFy;pzg?;l-=m`r#Lht!fyy z{$Bco*c(UWFEc0a{wGnIqx4XiF;5B61nB-uSO;li7>9-3C*5S$Z%{-V(Zs zlR+Y^t>KChvFiwza_&VQnyoz!8Q2(PEfq(Nu}mizVP&F9nrqu0x^)m@MK5GA!Eqch zJNh>SXgOkwc!2x1lyy!I8NjMiLu_~A;lHJyKJt!zV*`bN`3rd1=(LQ3J?o!0YvbmQ zCO4({%3N2IZ&qsD2ChrG@&1oeD^b*U;@Phm4|jZoM#zr#Svu^Te%^cR#dWB9oKEPk z0aU44AE-Kxmxxf}_XfQS?2rp_(Cj}6UZ?(D)@0mtPfE&6(8Y^v&LJW)*j#t>QLgR%JUme_(i!Tgqs(oM0Qe0e&RBVxL zSPH*^^?U5OwAO6x0~O6X_k$?QG|evlr0=ODJ&AQsL_JC(tQ%?uagSL%LMntsY**4L z-&H2+4boAL1QNbLejcMsMuED;2X;~eUghbs{glSH%^#xooZ#&y_j48Y?I<;^zro$@ zY|dtp7U@hXmCh}s+f%V^cBJ4?UwJu?UXjNk&7`9>ZhiJCba!OlUx+Slp!sYyFraqS z7Wc{OgQvS`$Gg)(mFvrPRaoj-{DYn&nb5dK4!sj zwR>Q5>j9#}W+Mc=hdKSAT^`7rxnh?8V@AxF{N?+$kCPuOg4cPE$sup9%efS$o_o(K z-%zk@y-PrysET|94}U^CX*1MzJ_7gEE#q;6A$Q>7d%d+j-I0u?&eiw~^??c0{4~PS z$IuXP_CfsW-rNBGt>OH`?FN&?reS$QHlbHT;gJQ}SU0W@`zLsTkCsE2sr2P+32BQ& z+$BW4@Ngq5RGt4ty3-Qew-q5B-orGk7#Ych$%mYp2Jh7>PP?01ld88JwfS3LSXI(E z=>=ZHD=!p}$naJfF(h#`>b8_G7%p2zfFDiy`dyn#c%&v@_bBIX7lEGja+q1)VHQ8p zk>HX);oI*WU755}r^ESjN#$EJjUlx}1vy>+z>q@>Ij~%a$Tz`ca$dVljfILS?Gm7( zm){zEda!7jTD|N1;0;;Se!y|T5WFG3S?RUww9icU)6_U*&yOPb41$4~1>#Yei9~?- z?YX6KEv}aZdPdzISV5^{?-H^+!@R;{WZ^MRd#whg!aKu9x;t@*DU&lD{AF8ygG2R@ zIWDzk&)DuSHU%$(LQEq7Z&tXwqpn*_Az@yno%*$q*JqixLzW(Kd66k}aWagN30Kn~ zQOtmr?H|Jjpgs1(y#4sZ$j+{-meBkH63F4T2X_3}WR<5!V7g^D9(U$k63+)cr#n1VmBp4Cbq|ku;iwVN8SIzd)W<|tH1yWV=nossi4TiOSYhqfTqE^5`l+DD8L%3eguGtT$ZI5_jN%`!xNHR-fk6OS2b^O+J&0SJN)!@D8`Zg@@xkE+jnM zIE{|GDA*MRU^$~B{&!Gv1bn5FN4%XrCD_LylJJI?ZbWi`qx6y`C`PM$uXPH;_n`rH z3~n>6j2Yr?y&Hr2t1+-zgo3iN-Zj6rPdev3xZOdpdAUV(7wD1z80Ws+>5JJ$qhG!{ za5%dBHzZWAl8yu}Ew;G!VW$C(Aoqof;k6t=vsnF4(RSu@L{je0N0XJ6t*%xez~%kHQr$4m+ENbo$`rqLB6g}gdC^+(A&t6jvPwiUVr z-?kr%PdD3$TrFiDQD=3nPgr$suQK<=Ed1Lg(upy$1R)C>k8h zNUxXd7#o{*Qx_X5nUZfhbad}wTkV&=p4+gZm#z?Jr88a)LEtfA>|kZ6%7`jtQ5y5iI{Wu72Lqxv_40WN zdv0pv%~W|R0>&86;uvq$_A~l#+Bjei+vQi^%1&8aPAc9XZ^14ww2hd`(=hT;jP~D% zxsxBJI?&Kc*~^s1-xv6KW{YvdDSL3z3cuA_Gy)LGN7`xPGog#jZ5H*s&F(0BP0hz^Q<)`R@`_PQ zh*rygE>%)4>(Su^!qcz`jOcS+(o2L?x>ZVg)B8eD9`kt1hgS>!8CS;`mTnX2WO$#^ z*ek}EDp&)#k(242(eD3B0jK`vF}c^+zym_(Dz`hi#s5d*zNv#=IQhQgEt5<7EpKnz zuGk|LgR(*eSU_OArp`ngTZ@*I$!8#hsxY{1myNa zJ{-@VvFQ`d!Hfq91WW`;&O1DKtMquv@ixevLBkr_H{nOSp;;=;pE%r#EjjCwjd>df zqpvvgZ1hg<$!V#CuY|#?Slw73uY_L)pjnll6+d5o6TNq=Ff=k5nZ_8t5jc6^DIy=UNn<1(bI_f<)*j}SJ(7I7nmL!yK+TVL(~#g0 z0@#;?Z!U-SSxoVr@TiauRco8G;0O0vss+mIBd<&HSdQhLz0P!bk%+)vhWIi#&w=() zPXb9wuxzVYuh`NRx4?|&-3UYoZ1f>W0;5bv4&4r?(|{|3F%RzI*v^!$vFsQwd3IlPu&MEZ%UF9gF12^gI^ zoc7V4E>16#w}LlXR(wPS8VF0BZlO|WNGG^x|o6PcY9c+{5$RcsoWNQ zajV3Z^r$l4-8cy-R3Aip5q)Kf;oH*>T=Y0*xIn-Bmh^nwDM0YLk6}v7C8a<5oQ2)7 zOiC4^Md61VU#vK&jN>u=?%~}$r&cu$o_IJ1Nvif65Xd#EP$V|6E!I}2NOMl2dtNSI z#`P5;bG)?;bXFDpR@jql?NPc|$m4@<|CD-u*0d_^A>0F@Zz7uhZJO3Pw4-+b4!03n z{8<58wBD-C?yDGHTs$Hmu31k8_@CpVuD;2{NJ4BHPS9OV-yb;$<(Sz{SbHzKqm8(DPvUr`oiBc zspReysqk)bux@BmNyOi@!E^>?@Q4`KY!|g~;p`(&?{s|7%nxp@G{aN^VG4pD539C# zo)T-KL$rzRkfe?0{}56>;dsT<@SRV5KI=nTgebYeOkdv*K)4p`%6hGX0ERm$gBK$t z4{RQ8CYYTjAcAj8B3cMz(iGS+ikrMmR%7~sK z8?66@+QO4)l)NnKBPe3@cJ8)7O-M|h#7mxmNkYJ*#1PNSF0_;c*$o51K&%H@giuki ztZix5smtED$NOBvCL%-lP&;q=m2n$Na{gsC-?0p2F=b&h+5=M-B)oLG z1YW4aQ)_FfRE7TsL9QbfiHZMs?Dp49Uh zI(;M88SHhHS1|7l zoaGjf_nrbn3dxB-$m_9y7ou4 zVePRq%P&i;E3`f|gsNr9Rvuaw;+3`OF%abaIxRf_|E9q?(D@8y-p6C8cJ}e`s8Lq~ zD+#>GxeNC#c)u5$bHNhFJqgU%P*q$=mzRSjxB|Jy~<=;4M_kv(@Faqmm zEO$jI6R1Q%zi`5SFdxcSzF1Ny%F;|K{ct`Bwd-Y_J%|BRQHmYrI z34fV${x}5-O~#g!oEG#6o$RH)LEwa4;|$g&Ytw3KA!S%cLW5oUzlEq~^n#eSQo~?~ zhARCIFRU`s;u%+n?4rz@ZannyE5CT=Ow?ZIc3RQ$A+>=_=&4EclZjn*r85ykpFZqm zuzaYA5&a@6A~aEnI2aoz$kAHxud2Ul$irVtI9`$ALCF9b7E*g zwX#gvH=H=JmZT~9UE&R0WeZOKNr`vh;8g9`^a9Jj?SZQWy7${|ebJ14b@z?Y-LJ_{8*m?MAg&qMt*d#g`|N~Am1*Mbt#;I9^siB* zm*~c0QS$`{i{On*)#fq6`2ZRNP+n#D9OP%=@33ZKyN&+}rgVn6i#eI~91O{W@T&mJlONFR}(D zKZ`yOXrJr|w67Q|1B-E=O733MWHx>2$~J*sq?q_`A3_<=t~#3Gs$`Tly+n#mA0eja zB?mZmU0wb_HNKECFWLX4noEMy7yfh$%zgQZxOW zxPv^@>jk;00Hjl+iq*(9(3lxV0w9Xcjm!wx0pS@6(HpR`=CQlDKV1tGA0mZDIt8k_ zuXJjJpBlN3tp(+fF+qB-7XI&a?P=OOxu_Oj=gtKLtlU0z`fjAB9~K45WTlRuZH$VOr+h%TTcJ*i#zySdmnRXR84scbak26eaz~?)m@#&dN{gj z4&a4_1`-;(LE1JHQAMtfELX@4v*`rDiqR{6lKk}lzYsiA-WU=FK`W>g%t$)zcqDY8 z9IC-Dw~^piJU4h;?BSw^M8VHK6%l+a29{d6r0;_NZ0D!1Ght>h1|)38owPd$VNah6w2mUz0v9L(m_Rb34-JeCFJ5$Ea| z)`cr6dUvwj+v~X=k54rrzR&aEdg<=yp@vz~{Yk5V7aFgUbJCu~6c0U42vpR~DHdEE z+DFR98d^;dg3I2ehNP*Lp5L+C5BgwNwpr3a6%0^PFy-w4z+2P)0C?fMJdn+(&?NkN z7Q9jplVHXkN2eb?9v+-FMSd#Ub&qeMMj7)Aukk#aE$VrjrCrGg0&^b9x-{c!4wTJy zvN7o9s74}JUpK+WqFX>7NwGjtvej{X`b}K%qPtE~;6Q`E1bE!tB9aNII$__a7^Ir1 z7#-o?=#M3|&RzWHGW!Ew?^Wh4ux_1OJaxfJL0R|s7tnR0`Ytir6mPpjq3I+hxB4b^ zWfymK!^HpVfPN!sHkI1w+tKFLNul z{=gV8pzg+np&op5EIb(mnG+U5#<*$0?H!7B*(e4@)?f|EwgxB4>mA>N9g0m)p zOlo$vr1|cyk@QG8oq{<~O6%9oa10B2D(#J*BgozcL_(0 zkN2+Gtl>Q-a>%>|_o!&|$qd#dm*{9)=y!YVe1SaeS3sd+wAaR+zs0MW-$J4RDQfGD zU|un?_!-E8b6HPG)Z`A%yZp)EMSh~*l=tl6aKS-ePMXDUH+Kn$``+H8-oUa{{JdDW zKeYKxG800Hwm0w9oN|7mQ^`5&bv;AL4~_v8@3xVHYNM=fm-K9BL4j0?6$XUEFRPa& z&mMUv<`vpD1N+Yycdi70j{E(*qyO22X6R+eEPrssMkIeQ}O;+2dI02P$OIk>} z(O%OfI0*Px*`qmuwrNwH+_>vqYg2^61R#qaWg6m7V-Iblmnl_TQtjMo?YnAA_aZ?A zV=JqiI(p*E+z%Qp%Z#+*zwh5h*O&bdC=~xZ zNy$x;e145+$^%cS!esM!9fPl#41l+)tTq}>*D~e5+kA2;Pe%ND~8W^x%;uorj zv29T^Hcq<*5>6V$9Bv}czfsyx4Uuf@x$8xMZE!|`qI;Bp@j-LxG3{r{MD_#9(Qop( zb-XMpuLGU{!nKwwp1a|WndZnl4w z^Qv&*7PU<55B87SHR|txzK$NS4H@Lw1X;Y8Y*N#sMh98t|9$OX$V6|K+Y3Ip}Pl1M}=l z2y({%-!HEHmWS3e_+Wz>@s2_fz{US~5;M@yoJ7;m5K?)*RK$6l8Oi+#Z$HKS{sXJI z?AX|i-4EL8T^Wlf-*T(pYsfKXW@f6`BpLqrZ?opSx%C^0fwC1qMj2yW+HsHNo@wp3 zw#g1HTVEsvTmTOJWmW8V8^?=y zDL?<_6U|cECZH{xQ|uA7pP|R*=g(AJ%-&8XkQS>alP+XYzVc>x(*<~v!pD!5iE@p1 zp8tK@AlnTv#I$S`Vo0s@h6{x@Ppr$uh0RY)Z$+Gf+u)%I za%|lz_SS#lQq2}kYi>?z(%(En)10caloX?sXzE<#7^}CqYu~1>P_Or@X`Q6jF&AG8 zLdxS`|9b zsEDh`(7ud)DR?GG1~34v)OaDymLob06qsTWyJ^bUz*=! z0RQ!Xln0G|bao{jmb{-_phbLZ(@POjIph0ZBqoa}~e zp~o3Z(+Nz-zw_GDzS}*>RjP!W@~6a5U7?6PmeEP#c^yak_(M)kuDh3;j-F3%vGu$n zQ8!x4F&uf>+EEW;i6mstjqd8SXacst4FY&=`0ED4=v5hvaii{Mh61VE;JOgibUJHc z;|@{b0F9_IU(h_-_UdNTdZPq>`jfa&8@8=PDajcX_CeKs$o@0cB%%1?lb#61?i{;7>^A^w3ORr?eySR14 z;=i^93j?}u^UK<5AMbGWA1qm}p|pGJ&SD{~v1x`{_n9nyuG^Lxy=a=hZSK4C{-bEt zq9Hj9|NQ$cp)}=*5ru3w&CoDKX4*Jnl6!S=l-E53ofwtdkVKWalb*%+hXx0q=@$a( z$9W9q`ABEw7R$dVk|8=;(_eizFDr+06lCc;Bkl44$w!d4p zd!P1$-cZa5&66wwNjA@?J2|IVSZuo?qRn_V%=iMf+}V(!Fl=VpWKcPBgIyS>JodYDb|t z@K_mQ60QFIi>lhaWcQ~(?12Kvodms+=wh=NQ%prM2k>o=Qi%~=k;9cu3k5lHH@eS9%z(sVw~R9*iS{LFGPY?u(AK*?V*cvMmd&`9JC(WUk`(t_%6<_6r^v zCetP=mT|%QwE9@~V#G6Dn(@RN1OZ~d^06yRNXvG3KB36t>kF1>aE$;^AwI0kikv*3 zkjm@vD@{Oj`u$3Kx?&ROsQw96If`Nv1~Ud8uDW+>dVeK33n)S#U$fy_V?OoemyuJR z^ai>Uihb%GfV`MErzJx-J>R}M{)zSu1An_!W-38!>}S7&jL#V_5oij5`4{>Vy|~$) zX93rWjbSJqm%Dq*%9AAax6!^_#@v5vTOu#RB#hrto8D!Z_+#+9r9ES0CAF%?W_W}z zjUjzypPbGobZq7#rS3bNG+_Q+U%U3}2CMfj75_Fw`q(mF(9`?R&x%>w?3G&G=`5c| zzhs||tZc2R>ihKX_$6xddQ+r*)2lC?I10CwajFJ!Vw6C>2A;DEKy~8HHqrCWRa-Qt z_C=Ikx(C->(xEqmwQ6wQR7SHN!r@a$W_iCLJHdvkgj4n#=}|7^{HyQ3i>gGaUgd>y z#p2|}6~7o-dqDOX5% z`r}K8vgpC+(r_S_4kN?&^S|NYNb2b7?nnCqQWA}83&uL=Xy=+kfNZjO9`dp-5s@ts z85Yp3wgeCF`*j8leL`9ShP>NxKIpcmLKftCz~kIEJRh}inqC?;|(!+Shk+uoLcn%}Vit=OA8=w1(`m=53ed^V9|#&@ym z`_>f=q?ZXBK;t0xpv*qjP*&Dm|L}%0`Uy1pC(kW{yZK{OxawRa269BCJQ`wZ95dXNhnjY*lCZPGOvCebRPxw37KyQ7vzX#tI16g^DO_cZm2hV z{<8L15!^rWoNe7vF>JtBhdsB>9++HLkxkD^Pa4JO!`X_8*)IxM`-~O^?9%il87Y$&CQy7Dm zBRZxcKM{ImdNwgW+7?l}9iOtPVEszIFlqnLpMAQVh>v+r_CijeQEKds^RWo#t)jb< zaxERd`tlnJ7e6?#`Lh?-G8OUJ&ITG>T`E{=(~@Ued-kb-|F}HllMd(Z!yp#TNqT%< zuRgO1JGb(8KN=G&n)-6 zh$tl?-2zh5B}#|jH|BDm=bY#H-t)fvv9~{k#aeTYG4A`mYDRx0c_pYqbLbbyQiu%d z_r>$OY`f|iU_nxYosEUh5Tna781Ii#w52jy?fb>oXUli9v30{Goz7qVTNGWO={II8 zF=XDKUtcK;7o}D12oFX)Td>ru_EMG(G27+p8Z$Su_LBpzt1-2fq0$9fRayalG zyd~J0U83;R)1km?8jqB?i%G9(NKsLPFQW@jVrBd&FgYbAFd^NeMItF(x#HeXIbV?C zp+3w4Pc4uS4a|CDCQV`?sNY7PMmjzE2EdIig3jtc*^ui&1!b=L``enk5*CZP1j>f? zvno%UrNKCGl7PbST4}BllN)Inzi{cb^7NK>KoP|#0ld5`ou?R+`Ie2$Q2)=y{VqNy zoe9Sdj_Hvn_r)0Q)!LSF%kqJer3d_8Xn9|(pOjsf zi|I@emPOT!Y7V%F^Z(g2Hp^kdKJs9cgsGlKuH?oum6bAM>+nA+@qOg-nvqdrlofTQ zx!O7pLO3`FJ%IxaJJ_lO)rQdt9joY>sdR6(vSca$cgGc~`P2Oh*I}h;EHU`|TXm0x zh?10?J`TLx2dKoe5%CFgF!{e+yZh-PuC2^cdssRGAr|DTQ)R|SB2-MUBLy1LB05v^ zk78zj^uwJ)b;(|p-FEQY%13!eotw(~h)V!ZU_GQY_iKKKI6kO17Q@nDQqg4mX1zVQ zdnB~uLco!&u+A>b%HZ>cNF?$;G>pJZ?1@k@8NRNDd}Zyl-dAkx(kXQCdXC+Sj>yaj$KlXp*peS_z+f|77-E#%)|6CD zRja(#5!~b7;lWC#pLk0d*1W7Nnn>sX+gpfU>vy!__i3jQ7NS62KN6K}g9VN?8A`;l zZs~!8QLNSNOzZs@iQrjp?<#c1&g|P1sB2sJ7y;~=V5R|8?LlK$gDURA&-sCs&`P1W z*)Wb+ES5Jo<(g`$wpsdpc%sS4B*}#fLj;`Syy)dmKC!Ua(UWp)HTt>1ly(Vsi{7dJ*Vf zos00W8>GkTW4zo0P7PBUeX6g(Lf7kGw_SEvvIn6W&dz5RY<6f^IG1d#Ck7=H5^s<- zdS4JPC}&N8(t?3=gqA8`A(q!0zC5m%7<&z%2jyg>->@}nLIwugJv-fGWir&usw2Ww z8BHIjd8^P+MpjG)OdETQB+j;Bs}jH=^9tQZ!$;C%QkE11FpJ|iR9*hiV4$9CnH%+e0Ov{{n2Lsr zR_Qz_9oX`~g(=0lW8Z6139fsB-?z?Rlt3<)qa}t)JicvA!HW|%trdW;uDVpCjcn^7 z!p=mWjn34SF8X_(sDmO|S&0#275;l6G>CW3KAN;PRu<`}%HhUGpaxO$3_;2ky6EeRdo#Rtc?`K0+@8-i&zuLx|eRV)qBb5Vnl*!~d_56x1 z+e?YBSv1MkvJo9Ht6bHw?w#i{dTb}0n5?Ajd-(!_M8>1heg7Q8ywI9<(oG2oQxbg% z|5d~zt4K;|-OcDc|4z4~OmuEk$UOBDv~dH88twV{q@{nha-Nra5=IO%qNhY)qfsOU zn}a&qGWsf=UysV~D^0iaoHYhh%Ub5e9~}|udF1}&%kVWUmgCOH4}T=lC;d(pmj`w>~!IB%CwSAD02&OmKinXE>QCiuBY$fg}!FxxlvYXGw$75tCRiaEJK)QaQ}r zp;c(l4yI{0Iv_n%@{>m4cW^#HwIcD?`8x&3Sif%Qv^HxzX5-A?*Z;kxfA2l|z?wa7 z27icAse#x#nN%s{id0tCFO=XFYFUxM)iV8$gY(7|rLYLsR&zOy$$I!nN ztq!sAjFemFHeN?lYUf;Hs$-RcoFZJ1R}LtVJ_yBa$^JUt>8{1nHZyfMSzmJkGVd>8 zeFmUF(_NIC$D*_FyngGcXL26@903-rAN6gP6297A#hFlqJMsiACsIUi%|_HVS!MIR zbe?+|e}7tV%SoA{h!CIjmL7{@!w0W$CSbDWpq&CB;^)=Fq8XvEZ&Xy?eXPB~eLmOa zx_nq+D5+}7U_nUm_=A_rAo{@>%MSG8H1U7E(7c2{`;FUBqX{;B_a}`-7uB+s- z)vK=VcFGw%Zl_kjrB%%(lV0e8%h|_Ro|7kX%~i@ks%Mc9jXzv6w(UWNBihs@l)^om z0JCQ``36t|YdZ-Xr*u7j;H&tn41&vANbF(oM+KJi;|M4dN<%mrawgOcl_n08?#YQY z5_sBH0wIxMnJ$|YIDuXv_Q3&)S!a0q$J7yPF2OKH4V8PmLxqx{gZz$ZhQfAyeW*_~ zh-WOZsZP(>;=<6r=2{$Y6laM8XnSI|6uyILBQ4rQhdZ z84Z&(!4j9(gh)16LP?x~pRlpgn}cEYyvCF507vg^;EpZi0lb2V(s&}u<-&ywgD9iy zuHEe)bC|`#;|-WYRCGd(D%SB_XrSkA;6Ed^f}JA+l$xCZZ^xz8Y)kl59Doug^6eCi zTl&HEzP|~qL|w!mf&yVQUJ))QBP$-{0$-oC0bYg~@I{`OU3$vzphRJ$tT64

{ri-Ef$td!nwG^OpBT)>grl} zjnuwp)@2{;$m9oU7Wy_Db;Ay6pUdTSJAdGcWdp#==FwIzyqL?dwr(Mea<@1hlsMn_ zTr_zwdmCdoxN`@J5)z~B6Ul$sqhst*7bdA+4la6)l6b6H${8}^?*U*ZGn9k}q`90> zPiR?u!_H22MfaY@Lx^LLNL8zFJeSPHIZB1HVyMWRj;P#G)rUBnU@!7F{SLDk5yCtBOvhT!+-DHs|~ncMr$@@lU%4QMyr z1_c+Vo^WYB;OQsSMbBY4^cPHi>)ekW?l>BK|H0Dq$iJ?wxtl5OALdH^uT|_nn;Qsr z&3a%5Mu?V31V5;YTRr>_bz|cA3KJh2cFE-0Gr(@wcpn@?4Q7)MlcvuOl95{ms`Q1= zA;$0ALKt9g)yZMRTvd6?UJ{HB+y%U@;^>S6;*zhW9d--d)XKlVC%mtresoWTsnE}8 z8c^qZ@)B8NMETG-O#W=%d`oiKL%I@BF)d^=6_5ZP&-j2 zh!}Dd%O=H=ma?#vdUto82I$7<7D#cDjmOKYYe_!ML*WQ?lTgs9=s{D9Rn4Iw#j!@8 zKHb|^nRWp%YZFm?vgf!umfTlZiGoVo#DN&_E+YXsP>;BelOjuCJpM3~(9C2` zM-wTW;_w372sC2w@ZbsT(gp&djhw*huB9lWF+a@XU3n)u=wxH%5}d*5b;vR4y(`7w^iLctk;Vztqa%m$$Ea|DU27tKHxxEqtgj`G ze(!2_1PU-hMauQtpp^RAj{0n2*W7NYk#Rr_9FGt&qoxuQrB88x3t67uB(*~Lk+1{c zAG|D0$JXo-w*@Uo5o&pH+N=`%d>_3~`fY-wV^D)EZ^^=tH?o_ObPZcO>hsl}8xP&t zJUp9D!YD>ZJE_y8n0ZX}NhU-hPvxwb)v!D?ZokRzHl|(D4=;gshQfNSd)HncP8(}J zhY`rYmac#JK3fjK{2BA`0}9{}n*jC4v)axG%dNFRfp>-Qb-N&=fZb(!v%fL%0^YjI z{6^d8&{shx5+`RPJCsq#(1CeQ8fQ?vy;Ax9-pdV=+QCtif?XYn7&^@a?0$pI6mLL#pP8-m|(H& z7GG>QA<=9O;1k7e&R3H(9hYd#Yi{pOS2r9?Lkk)SKr4q074qwzhS9JGgxA~m0*RAv zuu7POwuIPGsZ*j)lCTFpz|4gV`^#!vU!&o?M$#in99 zo{M7LmN`C=@|$RXtkgCp&E~ZR1>cfsq1Nh=4b~vv1Zv9Q_*yn3q=lte#(T|wbHfB@EUm4IkTodsN?bfY5*%;J-h%8k8~-`q)3VM z0cIQPO%3$3j}k5KU_v?oD|J_v*k&pvLRtA^#`%?yG7$_{Vf|+;&hp_!8r<)u<>bTf z%p)goIQAYYC%wY&s;0&IC`z=E^gZ31t!m$Rmo(?yKFy%#8EL$>qCt=R^NfRk$r4U9 z<0DO?KDAxkJ}q45CNXRari$PF)Y}C#+J=Tgj+48FMU=ZimWK1ZZzG5DUViS6v7TvXN#ycX*T`c;c#eGig=M;t{*@ow6t0lD{)SVdN}|H;vG&}kOCITy)EMVZ@; zqGBZ3$s>S04h-*T8XhVOSbXy*P;NY-ug8up(F5~6`Z|yAb;$j#pI^2-&KY)b^-Uvu zDSdCkwy;ZUUGdw2h`UodLh^S9UAX=g|HHE41l#77CaJFh`cbz%GEimaL+Yb-i}jf1 zjz9mvDWVSsIWOwYVG5e0Qv%Ih6FUEhJ88a@2+1hlU)4%WkBYgp2kize9aH%1#4Dn#qq1uoxf&14jO34x8qi+_6Hp+my^Z za@p=UUG!FGl%jHe|4<}R?{@BlE_*&iYt+tWnx+noroZ_0E<*r^DoZ0e&&^E{krmzf zdbpEn1_;t=@ay~^fw~NpN=X1zAw)9A0Km(+s=~|D-Ehn2c2V<2VW9S&Qy$A3Q{nt8 zvKgFYBKW@XWJ4X$H0i6p0ARs?;xw}2)-Ki-ZeKpZ)@fa$g}^y@ywBuLP-fYQ>$ei1^$23983s}E@1Eel@#zlqMACGxUZIf_A5ED zAYsEcnDtz6yNu~q9V<(#t3h%^4RQ5UCA<&RaZoG|yV?sPt3HsxoVdm93WGT)kmUh4 z&2cGo*>s}|2W*qfRXFMJ^jzc+kwG$PK_D+;{V+&%PzGA5bp4bVBkOK;F#nZ zF&_d`>Nx64XVF`(y=@`;TyMQMPA?Z5?00AmQQrxd?inF`p8+;R3L z{OZd-0g1$|wXPW-WzE1$-h}>C8^>x!W^Y`DtlroK7jbC-^i+^uh4=U&)mW^{8pGEx z{?4s2=IHKP7(ip?kN}pJ{|AqSpQnUS)Tb&0;)MXCAr5YmA$dImQv?W^T1~3Lzs6RR zQv^l^^XasBChKAWKxY?eEPcY=w(rTdfPBzkeiU#k`x5sPe%frfJAj80Iws%ZVh+mG z*H2Gw6v!aDa3JH9A8VCOy?;)0NF9bNH7bc!b(a~m1yY(<~lq^9>{4!QQP zrM?xn<*=m}!yhN4zC~&0oXZK%tp(;uxQE;$Fz#FI6mg||)!_1n_xnnm+oQ(Yf1Kv! z;iL#^8TA8fXLqLTRZwhGbmp0$NXHh+68{Cd`HPc-5#6gC(V(K_>qr+F#r=k%w^7vjjJ&u|z! zo!&p8G4O;%QizToc0ir;1~2y&j{{qTE)1x*w9^?SXxw1ffq~TXLD;(Uwin`z=}qV? zaGzrjlyx3+Gk>O z53@sY|NOXXLTeb|e?a}SAc0D*9lR)kvz)o%uj*t1?ELVj5qE1!8yDPp*Hj))hK4oV zgQa}DVy|wS*X|@344b;ceYT4G(aCL_?JAw>ua2S*WV)E>EpFg17c_NlBELra zUFlcryX>i*fo<^8o*7Lt{_?3Ot^X#{(+l{6gK&MRpZF9VQLHE1B79yIUC(CTL=a&W z+JdmeTf~JfVlRT~>s>?g+~gIxGi*HI;#RpkL!l!361Wk>Wp86*ZiEVRO9n$lg zf41Ka#<{6S_)oliMz5b{Pe&mJj}cMvogI)rooZfvX8@3XJQLW1bZ2shXUo%=sKl%F zfdth1x-$Tv{^kEkbOCB5YFj=vHJ4nNHj3k)u_kh`6e(Qn@$>y?%OCyq;Xv#8b=;88 z?=OCsGG|`+OaA+relyur$MFQK8lU{=WiGEbYaNb^`+hg%h8mRmez;<8UNxD;`?irf zV)b>4^Aot|NA${By0{-!7tUd?nu_1Z2Tn^ForvRqihF^5=KP0^T-dhOBP!`~D8bEg z=jvRX8PgF3HEN21qB@)V8=CJk{}B2(RmI8}NEb0{M(9bCrb2_0l1sZK&&XOXdbd-Z zbepf}MofaIT-~s3CFA^iWt=}BUfv(1r}b;`gS5}ETuNJOKbGkURXGtg^FP0dYp&m( z|LU~BhV@4xSW=$;^V!HHP0(re(sE$$Z5hc^g9hS*bDED!fjO_@y|!KXI_^=3%Yv1| zUofOEF!y@NqbY#)isI3?_T^2Ke~93g$NF?mAFd*txK%Uh7-_TXq1QMoGy1b-1p}LBi`d-p$ z1DfZDY60o1uWf9@Y)0-It~!3DHY~EVe*G|x+;DQF?p&UGK+(`uHz0jCChFyI>*y2Z zIR7?B@Jc^;Ww4n{B9_*F)m}@c+Kcy7cVKZzBf1ET`rnx46C3=4 z+yURgsy$2d2q<2mm`Kv4-iAC=np&-=nn1@sn(LJujbg=^kuT0kbal*L0gh-d$_vct zwD(hDqc%ecT5{iJte+mix=uE=NXEXTq}A!;7nS}X!Yx$tSc+@jnMqgaC$46~qsdC6 zh@x3UKSBojn8YE|F69^a$*Zh2vY-_JA z#Q7VOR#96lLf$iiJ*Rnru1Kd8^R9PJ?Xc-HdW4+N*kxE@>}aV~CtGP>Y4Z6|D6EO! z8~7A4ow8D(kORsa$qW){d)h5S!g-l7D=Mt!wv2X1Bpx!f zuW*pa@+3Noy4*3L+&E=ickhbhc_N24XxE%UZ^KwP#ZA!|RHK#A=B@xg7nM6-@k}4F zt?mWgsu}onjgUItOglioJTRPZp@;rk99k4+f)V5 zaW)*kW__F8m{QW_j>L{Xjv}aQj|G~rL04)%5F&MHZCZb*HUD@1<7L6XAL8 z@}vpX?UrVm8-!C?%LFe*i+*Vx|GX_ixl5u@A!Rc9gr|8Do$|89h~CDrM5ECXe$QIX z)r0v1H{PsRx^Ay3x+6&I+uppxrk-az&elotxV<&7r|zWmt$mTm=S`mcJZ5~T>3i8% zP*LG{2j04uUg|c#&OZOrL0kihdJz_V7YutK5|jb3!{`4aJFM0Oy@<)k&JNm>53M6@LWHhD?Xh9DlIcxe#Qc zXl*?53eonSIB)^!{hWGt1(b;tX!E$5WFey2m`>$kK@o51SW+}|HnG55lAKg_=ST52 zIY{$mk^@5j_yh`kw_1anAH1yq%mXpQ*1o+rl6x~@F?@gC@P>v#LAdF2SEBEizE02| zd}-k!Jc=l6S*|(VWo;99FO!x#=9OMXRW;rW<4A@#E2=ef=`gIP4Oc%34JY& zN-mt72iB7)CuY7i_z;(7uDg>XOcztx?qe-4%}f}U0XEI?a#3R8nv$?kTy3lJvPGqx znZCQ}wC5;Ltrw;h9=ATfIsF!d`C&8L;SRuX$yiR7yKpJR;5x7H0VC762%roh&^MV} z?A)SBU!s8o`sk^t*>37;0RkXcxb`?COfuFXUX&0JbgAKMUWH=#{c_miD_%P_iJ{rv zo=Oq^aor+nYLz5BcDj5iQU7=gonCrKR=eQIltFe79;1k}aDD*aB` z7OlV}Kye`POGT)zV6TeUhx9!0r4#7*7zZmmK};IEEN?ned_)7NB~{R zmJZk~S*)tC+(RyyeyRjVdgF)(ucM{YmgLH%Bhm$rF@bcufLpo@&I~G*rboTxL6$e6 zQn*S5uZpj3-^VkeePYF9flWw?-4NzaE7y@YR(Yl}D0zAD9B->(QcZ)xDQ|qFfMh&4 z2%is`Z{)s9w^qgq)HtYF#sni0wyvttxx|Yk)FQ#INAkwNxoYbvtu+ekDTXH))@rwE2n9I%%`de*>IHN$#K4ZoTuQybE{yUp!xS!M0gV0 z(?04W4395~F5LwT88qB<=;bBl;`oiM>}1dUuhYF4uea5_@42WINlQm-t1=b7X;6i< zAg=5Zf?OcGGHbin{`K^%PgH4AbP1G40IJIb5YP8EU=+>W01r+a>Z1sJe{~EWo5G)8 zfO+i;!_Ix?%Cl|#?`3{f%_`wK+;@Q1{9OYo<+Txre}-@Csy|qa_7b+vjcSq?1;I&f z*c9=D`P$lyII1}?4PP7OEDnC?Nr>HbC8BeUDCE;B!3rXeDxKY z9)AHFO@4khgEP*Jmej!T?GMK60g?ifG7-^P7uvvz1r*k!HPt?e7E&>d+Q{R27IG-` zOiW$ht7vi%0kd3Oc+78=i6(u5_ng8q51F!FMS^7I^3thU76c2=Ur-}Kt0;ekydq8% z|BJ3nx7voq`4cnl?AM3)w17hQK97uK_^L@xIF?F=*?A7IrDmP^`cZn<(Bz~pXYZLW z_vXtVz_klo|9ZUAm%fZGmiehX4xp3^V~lnCdKmyf6O@gG8?hMC8P3ip?$K?Dh^?#e0f)54SwoyG3J92^b`FR4oO8;Ivlu!6Npo zo_QV*aS>;DKt%#+GeX81m@Cf@)sMS5yjen!IzrL=rwX|x9Qkr0Rt#9m;DkUW7ffx* z8sqiQGP%xuQ-=F$G%a2pyA|1&LLC&UC>Yu|tOFc{>0PX?nit)2KgJU#BFAp<;2mLA zGSTmWA{D)ENU&f|>gl%PUMI5|ts6Z0=id0{V+7V!&G-@op$eo8I)Dn!GwSQN0O3XU zvnD}^|GTKFdrK365BDH_>NeO+P@y+*kL^uztjW@T!pc;r^zIU}Hkp{*sM1#6n`cpB z@a`F$D!Oe$CjtnZa3}$&5#~MFo?elfN~o9G*=gTonBv(&`D|{WN}xI%2e)hXp~)~O zmb+Id%zg~vHzIeJ%j{#$OPGD&Fjj52ep$Zk#B@S(1RVUD6j0z`CfUei%QuV6|vDM12DqyH#0Td1{l9`+L zj?E2>oK#Wjr(y}*;0-o1pEYUW3_-@n%7G=^5zV*!J3tEB0S5&`33|z|55018N2qWh zsMm$)ZaC4qxA+KfOwo|{s=c5v+@4aJ!@Q*hJdegd5(m+$P$rGePb7@7cA3G3K>z~H zeMLCG*;}pR-sBA|1>iq;KVcIu>jrVZ-%UR4MTMOU^=nO5e+L}SUu;FsuDBqx~&zas$N%mP&Uzxo8Ejng-TKRCVi!=x>X zPlsN8dbk#6C0o-}-sQApk|ZfLWDyF(LRwZ)%X6rL zEj95Uuh}$sVnGigSRA}iRZDpExJuoFwNU;fP*uV#mf$!o;n;wM?w;=aOgxs1h=b5j zZndTZT%iKa7Bjl7Npf9&whLoRaWOAeDU$kQYrsfJ9&26kUKXR3HY6nx>~2M_$A7A( z-Ouc~Fn-(bkFSQUr8eFaLCTTbFsiI2r>aLquQv8@`e_+HkuDj;5!v_K`wo^8{(46E zs{YP#$sLZnK+kN_PcLv#k1Jpu(v0Q!7BwT4Fq2jo_{9nc3Lw9j8fWmV-0HbNzV^Y^ z6?0#&1Y;ZvGK&C{H$Zh7oR3+o*#WwgyaT*5pK# z1`6SLpumItVjBSKM`A$MeF3lRVlVm~bL%Aoch|$yq?+_2&vS;?>}B_?n&w)lU8XO# zjDhf*OS~LOJrB6bwCnbl6BzRHWM83IfrN3V;pU>HsKSlkMBSs9fIo&Ahh=@&jVbgb z#5l3WrGV#!L!AIK--|m^LM^~m=0S`@di;;8Y*GvZ9|;ooA)4}!4s|SwVra6Qp7>xX z5H0_!2K!=a6B6cw`EhH*Utaj2$*EE* zqt)}Vu{^vfBiNqy7QYJCmpJ0BBIJ|BZ35+jotIx{0XqT1ILQmUW(|p8d+AK|vl*B7 zi4Afgd%V3iltMR<$jV!aEYt#d+Rj_iITQ@Xy{WQRmsQ^7TaGvS8yaY(4fl%ZR4-*~{m|JIBUBSL;I zA?c;7=8s#ds->)G&Lmma^UT4dwfApC*yzv5^t@wF!EKW`@yUjaafd2aTfzyh;#zw0 zvO9`A-)A<2yCoRW;npqTa#+gmCy_=?5ym(z_Dez`74>Aj|GzP=Y8X7?29XC;ghhT` zl_2BQAMpqTEmiqmGzdON$v65!T!^|VU9rgc4sPd)YcuDh`~bnVP;NQ{A2;wMt~YIO z&P9k#Zn1%fZ0yay$@7&DxBh_XD2xT-r6q3G6yZ3$-M-=v3*GRu_};j+^| zzl;HNbb>+~Ni~+4mUdKf78~|Ru=CO^Bz@2hs~4A)3Sz8hTt(T+=OXo3HfcaeeW?x2J=vX^rzq+_6c9YC_wxt4ko`9-?_*wdI*BxpVpe-tRH< zVQaYIjaL76TXBv8!TICXnV66ES>DKE){KqGN-N-fBwIOXYm1DHRM!5?vN0X|rJ=8n z(_7DHpAkl!oNv$)ke9l5AlDGHBzZ)WOq`uu>>{+petlhbEHh~Zma-~s5Z%tD6d^A< zM0vu)fy>ZzbuQ;uIhNE08+t*3kLETwko|iJM+3C~%36+|zOPFbL_(O(2V50QI-TDI zRT;4t6IDyUV1b;BL`TcyG2ydv*EHaGO-V-B&RQ+9TmA0NqFXX0JeR?^x__QcEKhH> z(eioJZhMU@(H8T>lO!K+h*=eM=%mMK4I2L0L5e)gMBwa}c=H8suGETfoVaJMl#paR zQ`+8{`$)zhEu1v-bG~~O#puI-xz2bY4Js^Mi!WM0v9?X~Mww4M5(xfeKdn+F;+*9^ z0u9U?*;iWb#3?bs9qJdXbOUu@=GyIFs+)Ab2v~X5FR~CKDfT*Y^pRM}CsWzEy;lK* z0{HN{wo%LJ3ueDHYNHXk-QSKmW8WpGKl?6Uk!rA7>Szyf9?^+j%CN8($P$=mYl*$Y zH$c8e;Qa!u0u;#oY0@N>-r9HZ{Nrfd#KF&vR(2OoI^4ZwXZM{!oaF@4rMh8G)I>so zgKu|5?iMVb$#HzUKe9=U`~1twW{AB5f);rLSvRF4pWx5s{0x!TY6WecDl@D2iqdZ) z-ki@Lc3X+|>ChE;10rqf{vMxYN0KR(e~f^CMu&~pZ%+Y7YMHQ&;khzl)W!)1gyUo2vZAs=>&&u8B+(ufR#b(TL>MO)ClQovV?=M$OF`BJu^r_1-?uo zq267W70mS?S_jWM+Rs9!L1{%C0RO@5S97X4AlzH<7-$bNnJ9|0PPP}xd4sK5sPcTe z<5G2+ZRQ07Q$6AtO-?cQtc=~C)v>ao_4uC{zAhb=B@;bT+);X&XFMl(Fqffb zSpT$PCW$mqu2#_Z_lf`M2A7%^7vbRNetav@TLWJ@$bfA0?j=he!VSUS$(-@&Hid@A zWC&~{0{Y0jw10dQ`6G*Gb+xVV+J3ekYhCEH2KfRMhOYK_bYh(6{fSGR7B;h*eMs*p z9+SR_pUgdEPe${M;Ao)G%>&PXbUKv;a``_rP2y#uyV%SHuV54iWp_gKc1U66%sw`tB4h((ub);Mk1mas*vn^1RiKPDkxw#-(85|&)^b0xG zs%$9~yYTgO4d#=3N_{<$SoV8Ithkp>$Uwv}9C&}kQ8*W{A4<3FVQh+l_NF~MAh8>k z8ae8M9eI2~dD4VQI$Ur_l9ilzX-g;od4IAHfN^^Er&bcZyl^ci_BmDyF~Kky&v6fF z+MOqso$!h1;3t$F{A~BnfXExObaob6`{AUcyC*{of^Xum;Mw;=DS+`OConTwb4tro zknJfZOL2kyfy&TbCc9Uo(&4A&=$bDcQ5h4fW?v=3A%|5PEzev}L+A7D;B7{bziuLUM`3W1x)1j<_Lj!BOM|RfDt_q`$IaGNO+n_Ls9#fKQ`+s<1w`-!k~>VVT!>hQTEU{;b56v}{t2b$g{LwF%; z{y#^C2}WRDOXtp*QW&XPd2NMPKb8`{dY`dG1rQM-*p@;YM)7h;Fv$)QAhL&%iXr3_ z7Y!(h4}PB^Z*VB$ZQ;tz7t78UyS_vYWJGT%WCq8(5aL#i4*&&kbbHpDwS+YYYx({Q z>=<+ul2F`sxxo^2QY*ZB?<0h52~fnuUcyHosoDYUCs+{qvlT#+PIrMtk_&@TA!Hrt zW&q&W%n$x+Hh6$|bz%)Gy*kJS02SI4U;_Y(QKdZ0I)FsmjAzdz>PO~3o72r?LV#aD zO9sGm4X#o=OSby9kW$tb20Ru1iBj!gNPv9bKBeLjN+h$;)&#o>CUCv6i6zS^PU8GO zZtsNow_pIev%J5^Gz3slivLf`zXoV*5HLEG_ZNl0?yvC?AfL)CtV*Py+$Z7Hr{sy5+_0k4&`CYu(yR{N*umA0tj&M=HVgNRz z|D!z(5({G*51X9TJOBV1hPqX}7~thZ7z;K9tGafy=8p#Z)4Ug;ZwYa@M_Y$t57Qac{3-ZbNE zzETF^Cp7E{<%Ytfm$$1hdL|1wokAtB?!C6M_2 zw7$na=eJa(fKIZ{T3sv`Detq*1p80E+KzJC5lEr1GBU&tpW6WDu4F-jT%cx+1!`6h zk>Y^75QK#ABLWlqRR*L2UtxOIR;3Hxzg=4A634W!v09(OSAr zh@Bxa{12tTVtq8+=F;i06w5jVe9Dv9u?4>B^l$!>5hI$sJBrSosty$_pd%CyTEb)M z331*R=Ormk*-&)l{ai7j2`ti%(*K$72C;$A6HU(kiyky50p8b?g>ru z=>5$K{jUSTG4x(1G-aDY9~yl9A08}<5WN;sfgqjXL_N4NN@DmE8K$Ww{_GQhw@vC^LBdJu$7)}^kj_qAtk{#C zN(1czUmlCM{QzkF23;VgijMUiG>J!$%rzYQs9YU_!g?atSV#fN{qd+{RyeucunrA#+p;v`8LKhLK~4;qb%v($ zqvn_i;cbbpe}Qtrutp;vpg6C$tin=LBMZRnK}3_El~5cWJQ;1IYvE3)&JjG@A;lJ3 zfa#fnXf`jfJq-%!AeSk&H5>r@zYuTQ@qu1wgDZFzNGC@KWTTyonw1L-X*RGP>{15`iXrK^Gb5o-=_Q+IK7AJue@Q)S2@H`kfq!HM6-x%O zrvcEG^Y5(q|Jf{sll<>B)5=`fhS`E53(i=#*zBEfwd$VN86BnM2(&z}^_Yl&~5PVLUM5 z!sg_UTr5X)C;}bzYVsC7I@}|hL<)JcN%x^sZQJ|MZy;tId={DfJy8bWXq>mN(eG3x zM*4f2Sl7}lq^9?bzRi0K2=L(K31t!xu<%R@MzQ%co(~awlo!*kKbd^}4csPHSyhNt zmX`s}BeX<#ijz5nlK51Cl#a_-tPXmCCF*^est!G>ap!j})%sKpv)KfNjeloVZdUdJ ztT4haYey{XWFQpdAjlMxS+pqt^n@+Uxf)h@M9wvdu4`b5(og!G^gX|jY2f0b6}{Mw zVD7AJ0_t?UUiTgsnW`3zW(Uh%%kn)e)h(L{d;MO^Xp{2;0RnCocR4PyhnEn1ww9t( z9K1V{po**i4mM4NxOFd8Yh!5u?ypHf>ja{kp3`+v7)_>TnLX_>hYQkVE4`mUzwM!e z!NO1&=WIX)q(v8q(|1xGaZsLkWwNjg)P{aC4HkTo$E-8Rs>wj#5Q_q~t|m37YIQn- zFy?=P)GlGAGoTC)Al0PWOxNcxhDORJQ{$l_cYg4}pYdSscsU>&X;Ib#JD+YPVz)Z7 zW(3R0$>jk%mM8JTv^f3^mQ@ZhimgeU0DZf}t66NjB~5q#Ap!ir%kejRn)ymVzdI zHK)ub^07yEh<(Wao1EdbgUn_>dN#-j$12kQw{12}{35*Qmg3~!EcX9>#45|m4oy7K zEdhKxDb(uxYd1FP{F1k2bnzBKlGUr{akH(mNKai(WpSyi2Xj_EPfWT#VKS*kK=MZ_ zAs*c9+1rX5@`Ceq@HYdT1>>Hwz{VeHHCy5`Ui10=mhqSfSzg$Qi6z~D|1c;R)QG|4 zRdI2(V)n>p(#YmXT41A=7rm9OA6{TYe3M|N(^xbO@{>HkU&&^^w+4ha7Pm6A>yO`ml} zIQ*6Bb|W!SHR9uC&(=U@1f9?zmH^0%K+WD{UXH<5 zgqt8BgS3@pp7GOq4D1aKC0u3f-$d0pKh#Wj!1S_%n9@z2KyI)|=aw5JV9Q0d85b0e;56JRt#GJCW{w7PMJ3jxL>dSpC|r1z_8gPQRG@gWy9%CH% z-Q&K)4kkFp!1c{y1Ec3d+u_9rpnhPf5zA|_XD6euuJOQ=5L|j)Y?EUhU1eGP$p>8A zF3P=4ZAJJvqJLsd4I`$Kzxr=4KYX}JBeUJ$35J3?K4jO7w)pZ)s`6gpK7a}GfQb`m zLrjn{N|}CgfRzbI#6gDAv+arTOus6l((n)yKQ#bUK!A2{76@XHP0&Mt1^OF)la0ip zK);2kYY=vf(Cd8iq)$w2at60+ix#(?63T0{xgV8X7{?`+<0f&HZ?yA_X?|rUsNLt2 z4Jr~=82{zjU%^ikZOr;V{i-#3ap!Cc0$UJ^TfwIWK@QJl3UhFwr}`jprgV0z#jzRl z)8Qs0x!RlDFhK@nAkv_KL>d{d>u#s5gLV}%0yAIEQWnuIq?jP-GX{g{o)^)vj=O_w z9c*T@%Wr@Jty|oOIp0ArX>+4;T9jN=?q%Be{dL0OKXz7;!LiQ}XOLG47>IjhA$DvJ zh3!HC<6+;3nAA1;{?)0j4hL#s7r3&8T6Ul}qv5I8j&7zVhU0eTBPrDg1utHz(4@*- zi$N}JIcllC?UXXq#6dV`TbC={JGY>ocKH>ew(SedGUSiGH_tVlkqNqSA|**0GQMB{n^-(m9=+ zij!amk|g&LS1rZ>UU<~~d|Jm1C^Vd2Hp|HlzLyXtB6@}R*PY~4o+8Z8+;?yD&OI2> zk%LHT9%f?yfJ=c((oEd3*@Vw&MbZCUH*P%>oKy^Ch|IAs!T{(8;GngwL3YkDqiwui z_h?k2o=Rv6lckSN4KoLYp2u9#BfzJl$-=gKzo@jk;{d(mKW{0u;z=<%ZMKrh7N6Jh z^#b8|gBaE_Fhk4x7C0S%b1+xh{>D5BB8(fsOmsCJW7dfl2DH_N(9i#?kF!5Pq})0T zbAxVNM{56TSpqpn$_6*6^uJ6Y-Y9e*F8l)}{2i&O@jLv~By_&mPSP81Y)| z=5v);)){s?*1QwOa1&fXYDed9L;W)}bW&mT%_Z;V%aN|{kA#P01HF}nM!C0)1_^0I zH27cN65G$Y(Ym)YoA6bnF<^e|V9?xGlpx~sq*zZ8Z0fXwsAv5FX=NA?Mja^!lVD>a z@df)F2kj_{OEnwSMA{rrmp)wBUp)Q(<9S;Hr7OAbk3X?oF^x;#OD}$55G@p?$FSrlO1drpjLFw|^KCIYohBr@@N1)`SbQc)iZi?dYD%D$x6Is02VI&4$5vGcEU?B4~{wb2NN zE%JE8C*TK*gB$aC>__)T8TG=LEsd7~JKYI$Oyl;W^OY~-v0cwoj!cMJTa~JKr9Z-j zu65uh)z9k36T&u0ybJFcJ))_Za{S!$i!8}hChCH??2U~|E4WO)_qAOw1ggPz)|1S$ zr=hoVnq_ISrEFMCT;HZ&o$A^hvP2qA`v127asAKN+uuJrF266IkGY`l&!5xl3*Wz+ z`|N{anhXO&!;}JG$_+Zi$iUzM^gM%t>ZssA2FR7ACsT|v`ONOtf81!va=`M-tA}5o zU5Nkm>+SAm0u0YD?A={H%ej4y7ATgw&jzXDim|V;vDeQU0u{CX{rmUFyO)=jpDhIO zo}Zt8ynbKZ-(UOr4b z@N#fDn+gGKZSBI(&(7{BdmHt+n1SKI{yRXElJoQRzkU1m=;`U{AAvUf`1I8K51+p( WQqtYbATc1)AqWgLbT>oi z0PlnPd(Z#8=Qs$qC$v0kxThrM3BS)7KyJIa|S;Tmpq>W19dWWN{1^EhiSgWnjpHd3I8J7HCULBMc3_ zmmeK{4hbnZ+mh5!PzXf=9U)+`ad9K;3=B40@7}%Jctl93e!wFSe9yxYJN6hg%LO4K zRG&;1bk0I|(*b?z2GH8l{_noH(C0^+!8361pROWZSJONff+!u-Z0k`zt0Lqg9wnE} z1;jU(t9SBPH&^H>vkI%F+4;HeX+&TnIA^w157w zU)=inW_j)T+1cNL4C_R@wLjAC;%dwA*?;&sENo;n&melTzDL6Y~B(67#PIv z`PaPMOeHI;C-?EFLN+#R>bzVJehDltw1)}0Z+tIFC*hJ(q>brC^CkZ&x%=jEAZ%x+X>(x56i=9km&m1Y$5Ym4gUoD4RvNr+q zEA~VVOnc69me2QmVBbq=ZEh(yy5RG_z+hy2b{C8SKlGO9N$l-CfrqcMTybTUh5qD~ z%aF7&eA={jgmHD+DPcNV@@~Tl@JBIhFcUDM2HWyXd(Ov5reiTb^mkob->d>J#pajS zi?r82z$keBsBWZKEX5e<*w~OnamT#f_5`B>f>W=_M`#CrVn`+I_TbZ}PhLwga=XD2 z=-ZV1c50qH->F8t|jU&!6;2a3#{mUN2vr zW+Vj@&PeD(cegH8i+2$zs`GuHcu(JMl{;l$M|drSvhM!G<|-iFRumO50=rep0UH#` za$f=1Pdkkm3Z|p{d!K%jM~2ihGq|nKHbdf?tYB}Wf9txqxGWJgC7dpVaYZL36^wo` zX$|T&k;=-KQwUw97sdrv{yPjSR@bGp!`5bi&U)>4rq_CI;u7@wYyi^nR@>kcwTQYLwUDR)OFYxfFQwmm+#cmAB{N{V)Uxgkw9U;KH|}*%ihokTiM`n)-I?}@_*Bod zffGhJHYxs>pjpc9a-va>i9>E~u8rae-7BU&41J$@$9{%mD26&5bQIfaH#9u_K4f=t z_DahE^&kS*cEgI{hgHvzR-5HGDSf_Ro}dSqfG;R;%n+>H@0O63#yN&TXeEAx(0p#y z)7#s6Fdz|yflb==m>k17B1<5yAfD+b0bzJeFyN8|mv_$RlLgXSKCs`P8#9AUTZJ4> zjAhJ68r1eK*Lh~NL*#Oe$3K{Kfkd#slO*w4M%qk>w^b7z6%-W}>FS%^oOwd%60Ks; zdP5WxVhun4nma9mPLxafB z_vo!qpX}kx#*?htuj5 z8h#W)FKuFC;&r~BzswNS;9i4C<8`Zc)~`W#(?^<*Ovu?nXdt%l@Owdt2 zeZRBi{ro45oIwSlnGVDGs-0$0VnKYiqg^xd&FEz==kr7B2{V;L9ikRZ@K<5?BAk-8 zEj!P^sX;4cCdortq zLCFRwrF|qJ%kkQXgh;i9TR2q+2M*+0oa(Aw!iY1o(s|6D%JCyB6 zru^C1Nq?FMYbyca%6L#!DEInelte=L^HrXkA4sXlUoQZ5J@)1Pd$N~0qmVb$EGvc`wFWA z8QOZtbaIB{-B$eGbQ1rh3G3lJWtT1;@JXuGX9VKS83w$X@KaJdch=~}+tKM4{5~4! zWW6f$P%)>yc)`3)wO=s04Vut;eOS8Qn7(TSnr(wR^h7`OgBFe_@phYCfRXP}{M556 zpAcW^HKxx_waZ`5v&endgF&Ux&2x<24BWj@%5Ihd$7nR0KO2u-St++PV8|Zx=X~Jx zoi?%0kPQA$R!FK7(p;Xx{C&ldYo>KEUvMk5? zpfR=NQmP=vmNjdX*}~rSa)HCbp15_&t{M-DvG-mJhme@hz|IIU<9A^{!LHy_Y0&KF zn_sH8h}>))%`W047->9=~nkfXmj^s`upK0jhN zk09frS{-Y?f=(Ig>vL?@hrCok&=J`SyAI^^zrKfKnv_DmBRdni+c}&uFy9*7TOot4 z;koiARRm+mm5E<$@jf>H+$;qLpCn95iAUO+KfQZpwZ|hiA3p%;C{7>aKNvlP>|~jK@H%fla=sT}tCU}FwGFc_@BF6JJ{tBr9`-XVY;LM@A^FfCQN3HR!vh z2gE-lrp9&>m54YCDCOyR^~nh%d$|@S^c-3^y-2zElLn{!-I;?fp1#B6pcq{;UM&OD z{Jxq!sC#{~^K%n9Fy^`KjZLN|Lyd1J_)yCLANZ2$@ z=`LoqUK_}FT8t3rp%H=A8+06Zg4O~wkU?!G;bhLu0NlDi^d!F5OXAD{~j_E%dz-`&r5l9Nvb zEx*1lpGiD5SU4Ui9i_XIv)CEctLqF)2T+7Ge^a1>Jt4!xUsv`A)m(>=+ne))%-^?M zh?~&I*of;@v($@58mN&^VEur^&s8G_NH2E>X!ShoBra zp;yI^&xtf%)L}vHFcXd3)62zyg#>H8y`*FCVRe*%$@e#H0ps;Mq?MY(cd8n8KAy&3 zwy~Y0y;f<8)N>e&JUdtTQee*y>T<)D#nGe$*8ipL0Ma5gqF4Sffn2~Lb<5qnID#p} zV*xvr4m5JL4MI$t_;Xb0K7ND9yOuWwp)=oI~e?~>Dn5KW;=xEaQV5lMlEfw&Vp&)llAOQ zi41hRtE)|3KObn-l{k-@342YYiEy{YhH-am6{MN~!RIj_2@CXX2vg0egr4DGCqC3j z|HlQH&E7fyHL}*(59^n*^wBl#OJlnnb_~)RzR8Yav9BT5g6Zvdz1Vuej>!#GhC{ld zVVxqHwK+rZ@uPFjBz~b+D7M4%XIu6^mt~aFgYOxhpM zOQ(H0eRU1sTge$IuuIxeeT3kS#a#XcJ&Dfk^rCOyF9J9zJ!>As3XX0h@_=YH- zS`N}f^kjAU{LJfd-gr?))J4X_T9d%CRkO<{S^Q(jYS`mom4~L|U&*l!0i53BzQ?6k z`3%-jg-c1qr{6{{?}w)BG#wXw%hkZF4sShBj|g zjn<0|JCP{WK;63J+UByQe;j&rI}u;awqG1Q5G>E7A9hjJj1NbH=GO+ZH_~7&+(1rF zu|UBBeGmApp!_-3^+zL=4k<97=JYytNaR)syx&TCd-L_12BMNy1{_yhe8VwVcWdDy{O|+J zIw{zAq%R>Q*@$N|jWX zK<*;(p{{utxdKxiLHJYXU3*T?| zE;RSjn^MbC9|;Oc+a8G7T)^IYJnK3jwhzrW3&|A=QIjGN`)qfO@rD3mG*)K7Zs|&l z3U$)FCogf4dc3JN@$ST&V^fxM;*!&;PYLwHadHq#;fpF#}>mv%bhO$ zABNQhB+bo69p4%XhEA;ARyC8UjZci@ zu^Ze(LK{W{_ay^u%d<5?lzK>Q>hP+EHyMTQ6eq@^I;v|+q(T*+xM^#JZoP%BS&va# zd5veTJt!_Lc8Sb`D{~a=`}MTS3-u6 zOZT(ft*Z-EE&ed!$C$Nv27Q3ZIi{h@N>{Wcod5EGBfK^CYgLG^z2wKMeF9mAjvx?S^+F72q5&BE@ioV3mD_!WoC+}!Nwm-< zkSj+5kiY9F()8kj&Yw{|dS-N3o@9nJQ%+a+D@Pt@P;{A5v*CRO$aRBwjuOc%DYWz6 zUYLX8m7hR6?e(dgkk7O2gcqrGPWK1k7bQ4B_jq_G*@y8a$Q*g0a3>pq8Q~Msgyh7Q zfeqHy!ee0f9c_-O!lk4Q(iSD`1bpd&y_e|+7f=}!sYv!U`tym!zqt52MwA}}Uv#Bz^-Ee*1}`Br6805ZO5fnI9c$z-6G12vitWYz*C)2BgZM&OyFwA1PCthVh<({h^%q|9_uU)MwlHpDn8to&L zqj4_&(dXZ|FX*k=XY~QPafGl(*%Xj=|PF7YHe<_=c zw6sC+rV|W?7iS)QxLl{{k}CwPhLE3)A{SgPHvJ3IZ=;;ckfc{;+bD=^c~e#fC;0Sg zM^TjkZd`Msmd#`OJw>dGFf55p1wQryq(dJp_c)3*NHg>_ITM#YsQ~!w#!gX z@ODh|x>%&_&%r`la%q)pOx-4YY7z$XuM3RZS13{e^bf^fIBluWp4Dv7cS7}51Q2HU zq|puXhf9P~ZEd@hlVr#nT<&!`AG}Skp{12DHKW_sJT8W-VAC^{aGhJ2E6w#~H3MQ; zDnxwEqY$WA-njo6`6@kxMxJ4cWIi}zdm_}>;n!Eb<{~R2MS6- zY1NE!kzMb``R&H(He=pui&(rSmW+GwDj1LYsqNFymqqXpOIFZs1U^kvsV3~FP1Qm^ zIFIonV?yxc>>U`Nx#hE?`gH~feR(*`!*?Q{dc7ceb+U6E-@151XjKaPKZrxxJio)h zu%W9j#gtjvnv-xMZ$l?dBym{-5ej=Ljm91zW%0czZ7SnBzlazPvuZf?P;KX6uEj$sHryx_CB6TE8v>J0eMYGaHYJdS>YL_Bw%zi(HTzvF1 z^po!90ex0~ajB)fD|1spSk}lw*jb8W6I*R)y4r%`!Zmu}x{E6fW@3&I94syo3%+pE zX0Re|Z4>4tw7WbXYfh-f{7fUC)v0cl8EtjY#TeD~bG~*4R9u1@nURiqMo0(IIC%J+ z#oSo(@Xk^y=(YklmY{YMZ>nF{)l@#T-FCy(HzfB3R| zg6=%d)*Mm{1tZ@}X4Cu9a~D^wyO&pEjORs^PK)ug?Q7yOeqJizj4TBx{kZx$2UU-V7~# zx1}Opiofjgm^5$9R`?^C(Ury&Wsw4 zD($I*u1i(Bd7tE?R6Bcz4LhQOugD=2dt`O0a!1k(3=CD)Po%4?i@6JBB!`Y#rFMHy zMR-t=3SM)^4ZC5JI~@a#Y5sMKkdTQ=iMC5KNC<5tUu$_HE$FEJp0>WT(6a_5j>K+v zqq|JO4bjY?eNk|2@cQzR_0*ARe>#?C7*eW#c(gf{BPi)Hw)7;H!0h((3uLdngRw9; zs&V9?60l-gdNXd9u+)G!JD932LO)LGzR}ps=rfNcr+hPmJ) z)sm8TdTWlyl@Cs*OM1VNh}K<6W_^xeK{mtkH^tAu2FF@{H ztSt_xU6p(8wRU@Ue=FoUf3a^PQ}^B=wD-%tFpu7Ng$(1KM)w2Joj0m-I3foG!thj_ zxZaj_r>A=9^aGrEZJx=$`o6=Z4KorKCqvhdfS`}xc&}LSyJ-27vT1n(CO(WS`BpwY zd1xZ<7w@Em*<+4~lQp_K!f%JWJ6fF^#fZ9R0GH0J zj$d2%b;df^mT+LDw06ekh4gbEXHXWHMm!zJdnXx7j-LTpd+P%beKv}l-<=OnxXrr= zLN=|HkLe0q)Ph4okYTld^cLE`LdP$x*n2#AaA5T|+VG<3b;-#7G!`FW_tQ#3?;5Q=(_`knRz4y!);80HiMQ7yc ze;>wJQXyr5@BL}we{S*r;q_j_eh>R#gQp|(^}kz4FFn4IME?Ni z+{B-@lxCC+lKk%-f}mLpJfq3=zeUMLvj{+6`rGzzZ2I5p(AfZ9$ChQAPdFRO@85wfVGujm^y^N>TSvrf5g)@$&#)f{Zzu zEfR6khl0zf99A!wur9utD7#C^zJSNd9zP+K0zl@EFjQ{qNtU4|VVy5;2MWfc_2AD6Ll zt=3ZC3?<*@6P-e!P%w^6aVxjG4Av{GD(BzpD0yZZQ+`H)3Br?mZKa)=eL5s1x?|78 zytd$pc8YNzym+&deH^;?ya|*$eBOF2rr260X`*Vk7DlxzMuBY!G(2V#d&FWuysKO-0K z|8P+4inUX}zymef*Szbxwgqp-f`Qc*0eraU+kjDMVcLrEn~m^n;B zPFlKv6Qs(dPKS&WnDM#`K`+uSZvrCV>BR*vT1`|;(P;0ThUf1{NeyNf*QmN*9UdG4 zWbrLA#DIL1YOA?A@f`rNm!1 z5eFpyc$tido}L~A`#>AFK+5mmYTh{e=>NLJiG39vdvb>%5fizI{b}It^WLX8yiK8v zvcHxrGE6vuE#%#$=zJMQ@!`9SBB35P{(P2!h*Aq}f}Nzj;T@Mn>J#JV(~%3(dIWzD zcm!WyaB#79dV5Dl5l~@)m-p=(UGWnFEe(wG@kJ#Ve8hd0ERwdkJwk3l@p0Cx@yVK&T-4ukrE{5|Om-<1dI(n(DIIldRinT?H9K#mjJI$=j2 zYju&>jK;92ehj#L_S8xWdkoC>5yMp-HrJzuV17qOJ%5R7W7hObg>T3#Z!j(Y2~Ak# z6{NkaQPwo8xvY(r0xO`%br&(5Ym@8l4Ni!#zN)qhp*hBR=gJ=GV}0uC$3hv$rKxNe zDH>#}B*i@p!4&7YO8bo*RYhUO1%K$VxDac;R}H}43_3PCyiNAhFq^-qLj59H)cd(O zdRJ;|yz(v?m*E>d_{H(0pxKc1os_MPcV7FfmX!;k%_1i>vGl5r9FW6c?lyTZ z@T|pQ`Y~Aa!0FyqJ$v~_8oAl_@k-0e&0JHjFz2Eu@u%;ig5vORtJbQef7UkJX~1k@0nY71N}Z0wjXUzoxa z1*VOe#P_)w^g;OR@R)@8X2+dknAMx_FSd8&+f=@0Z&zc_h%iroXiFw`_Gl+QZRq58 zG@Fc-Sj4QhGz~!xA(7YbKw9b^I2k5PW%#b!eoI?ju3?p)r*Y%wb5Fb+gz%zPuduWo zuW|Y7-4*MJu}4*8X`@i;s!N`L5S-VU~h&`ab zCZ3wH6!ELx6Ks?dm8&?Jz$b`*@o-Gwi$Fw5IA)o6P};@SvPVhuW6Eg0Gm?a- zn|zlM2i@J>`RDT8^QN@h!fjNX(SY_j;^47T3mywKBRNI z&u^~WQOKO_TxXrPDlGfxyW1uhklh-OFnRm`w!lPvm0z-KYiy3_5p ziH~xQ(zr(Mr|?dUcKaeSock)8PD7E;3QjBp?GKm2`M@r;>=unyBYO2^#RrT%=Q-PV ze8lT9qC_!-%autT!}Jc#$0yj^rgr|IjY>=IuSb>ILc1;f5p^0NLo z?XNHyL|#Y9f!>VNhI7d9iZyI!v2R7D(xziK5MArssy-FkCe<_4-3ftHnSDbLhVlt{fuM>pOk>v`idEd~wB` zmF=8_{xKp5bERD>5|BGyn83F%wwa2z2_Rdfk=rRR>o^Ach3c12w-<<*{R_8Z0~IDA z$J{>3!lw-UKYJ@``8{@Jcxp;lqooF$Hkr{eyiG#*2Cklr7Gh__snbVvSF7t9Qw>|q zgT8Xmx8JtLEh7e+ECh(gg4c07FHP+kKUGD|RR+$Q?8f1nX)p@Ka_{Wvqc=9Tzpv&~ zs^!Df2U`AxN6@#2wrfKV~C8`JyQJrjlB7!Qd4=&k`p}yMVO1;a8t~nIjYO1dh?1a>{@w z@w_M|dD;#^P-}*Cb!-eHap%3syMb0(1V#21 zUgMrTH)lb6`uNuxNM$-lEjAwERBh&GXJ}sVeLw0-tgvAH5!^42x9Il~8h26fXhT8C z^!(Zo4w_%;j{6tBfoK>ba{Sl%ZX7VVA({%ygf45`cLVv(_+CgLd&-;njY-hhd3;1Jk z;8z#r@a}wTDNwNYvpbG;Bri{|>E!NBNpMKPfgaD9&7YScU$aL1bDX6v=7K&Z7IEHe z=ClFuYSYh{;S642p3hHDny(`?^Ht`7icvXtcfO{}V?7*-7Y{NsGaq1M$4L~fpXwJj z*g)y5kH=BQ@-H2spZ@e9qY;%a=?_mzpp8+)$y=5s8CmGyr zu7MH;SU8{r_O7;}H?u{5DjRqx+S8{DLA=%u`->n8iDJ zzj8ypBoZnr90&w*pN7T@T-G$_np+lhLumm`9si~@Z_4jtTLlW1R?PvJ1NBlNFi_mG z+bMCSUV1xQE~*14Q_dOf>KJyl#}e1xc>N#6bVP8IP<={|aB+1VVIPR35i2sh4J`6L z`BLA1*P_KQ4>f%*kH-GvWI(Z1RnL!lczOCFLb`&){%-aVPzX?#omo|-QMwM0f56R5 z&CEvFzhz~;q6tX#29+tdtiJxkz1?_o7LDoLkB?Q{H6u1}_2_IbUYNIq5bo#yO>X){ z#k7q8YiqauJM;i+XQ}~S2$XsvNap~3v2(oAY~(BNpx$~5CheDUiPO2e2n3>HH5@ZN zy|^4OZ}ESm+;mS121}9>wv$?E1A9w{vu=trB~;tK;07Qn>C9ceLZ&_0;0P)Ty)&8N zdz?Hq3J?(HmX^IgtWJ05T~e%0!i>iMM)@^P%${t2RF6^n9nAhqqe&PQHB{*1-SqUy2m} z@T70-3c_f3NILh0O8S`c$9OU^x03ya0*h*TIKBj$K*VF~2f#Ee^Aoa!(pdvQ?gJpbrOFuX;kdm;VG(-Fp zFZOkbOIM=K#y+j|FSJR-eNhJK&yiqaMZ1dx%XuQ&u>CeRtTbilK95A`u2 zWUe(5jdhUjfK{dZ`*InxQTUEYK@E)Mh*6mkH^vzq=b0=0Swmk!_RfwML@c2M>tJ~_ z8eh3XW73 zKC_qo04O}ocXMaSmg&|`f}>{#tCbeNC`d?28Q9n!-o1~bhB|dv3w%r-#n^S6#N-=d z1_2X38e^uLmnCGh-liS@U?kg>IP^gz!Q>zyQ!v)|H@KW7wPR-%O(RKJD|AeKehX${ zZD|O_!+fvJsw&>b9v1Y&97_uOIa8r;#-_2-P#n{eHsGXl1CMc6J#r9naX6nfxW|2;_PFIDB?Lt&ySUf}!YxcrW-Sa2SKXCO+ z>B9`$x(t5n{$m;Fduvu6DZ#- zdaDBmLAT-$0l~}oaBa{A#X=!`87h zv(DpI?2SvMvayrmGsv~hstnC%&&E8QKCWK+{sx{5xrq)^E-ueyBPc%cTK0G8Dx?TF zc7zhMIR)ZLXaM}^Gq9JO4O%F}%7c1Nb?+KOsss_$abLO(J$RC~v zQtfH)9^f+d>Rt1pTfl7)6|lhf zrzoBx5shl9)}~*~-%Z@e%hdGj%IdCIaJ*2|Z@d)073lH)5q3IS(?z{C>}~3o!4f~V zDrZ}wZ{fuNyj@oRrqcA-_CSJJ1XaFg zrtCC1^|zv`aQHCw^iIk=_6OX2C-Wv6&d|A){)hu=d-G^F*3TW0GKW2kk(o9&vuk%F z=WUrO$>!z)aifFxPn!gSz5n|2$+`4Q`lWJWy0NR-kt>F3c5>UnAjNQFS^TS zee-amn$g!VePG{KQDxNzue--weoZu!MWudAWUDsYX>MD>*gvsG0d}St8@w2TlruTi zjNNOTd68?sN{3|w;o5UW&!fXCqI8ST*z+JyyK`O>@Y&>AtFA!#hdvxoy*%T78+BmVIpCoBonFT=dU-(Ti`z;eDqim8%MZv`2;PyAk?!PDq_DgTwu=v*hyGpGF=K_wBMOR5 z3Td{oRof?C`(C9JN$V8kb<F-QN*Rx=&NWr%}$8A72*cAItkYYwAQkqezFL8f#jzUj z$h)k6Jah+Q^dU^d`B#;I+IQ3Nr)}F2G)(r&E{?V$tJOHMpd2miKY_g->!!crOMfOa zuj&WP4t#MGSRvs)w)taP&k-+NaD72uQB35)wcB+xkX@mD z#Ajt=E@5fFEB_qNankE7z%Up}4K@{YP-2(-i8nwWCxU{fELFl-GIvWK&2_=j^WXaa zN#$**01RmWzOQgR_rCQ$38xdTu_)P+$ExjI4lNfrkK)cM57j=^9q%2^5x^F5bG+cz zU*lEZ_Dt;gBk%$ah7P(CUrpl~ypXTL6j!Xs9Ej7Iv(`x|$M|mGRaU#SR(Lr2na4O1 zao}_g`2(*vnu3&n^i}@ozyNV(%c#uva`zbt8G#Q}!m9@+%0&vGj&8D-0obYe(_BI! zTLK@}Ogff2jmLfLCb_jl(t6!4k82S1Z&mD@f{G3!(uP;e+-Wa`=He9ay(yXNbSK5h+?Vj3Lo zGOx!J8Tpp|4NTk8+Umk{NhV@K8SJ(dYAwGB#esm5=rvT^{{s@0CP{R$Ouqp1FokWZ zI(}=j5ckKOJq)C|QG(2~eKrJPX0)#aEeH!Y1#)ln?m^l~Ty=%}FB(~8embmcch!R9 z1z{$psWn4Ey+&FzQ_w_ugwE3M8hnav<`;(_$JEl@AFkl@?yUAk!^*g<`l7g>7;&S$hmZ_aYt1FaiwtYW4qe!+aYj>@%w(@+*O+OnMMsJTxww|{WdGkacp!7Zr zh7qnK-K_wI9Qw3b&q6!|^~p!B^bY`b{{RsS4xOKW;Q7ukrdPoLxL%kT&;CXb$-+D2 z5*6T~n)hrDJ#+k$S<+WY)m=|^`KGvRU3CA7_5PmiOoycnHUOfvJO3I*IOKt@#aw7K z)GK>Si0M1x1DxgRaf$o1Jdh(%|2?J%-9rw%Rq40O)pZ)4w%7;J13hh|{*7$vn1WG@ z7lty|X9t9{fh6lj1Ilh?*(A;P9YrE2d2v`>3mcXSYIABIUdxpE3fqd*sfv!0>jJ6FAFEnC-#0_xFv?sh)KBWxqhccZ!S74hUVU24>++;oSE7#|mbpi%SS}{MgB^$kFFhXk zrlvm&zsv1*L?c|h|sqG_4~FkAkzfbj>=A4w6R0OXK(1BR(l({&x(D->-K)zne4 zjsD^G&szG`O1FhOqw8!JARjRqR2G-DRk}UK!oLPi-f#35Q&AXd-bLz#C*_$l4j;(udRC?Awi01o!uboevvN z%$>v>(kMO-b2a;G1~FL|=;=XlE@y6~`jr!9gpJrP?1f=6?7r^c?{un$z=Ni9J&k)f zK~!#6r{axBi1vc;-X2_y!*^KY7rFrtaxyBH(`9?a`?{Rt8y$#X*bTDbIr_#rs7&XYbfsYr6F)z{uAs5>_t@`ba z;{x}KJ7dn{6u={CxBSX2uW3+PemPoyl2&BEYPxj#Iy_W&`l!~l$o_ju$pnJ-V6}5H zIR6a)lIDI0z02`er4D9%{K`2X=R11I0aLz7+o>1M1B0DWpCY^jhjW`^Qfvu)E^l#V z#u<)v`94YEDwF%!da~f}G37tj&do0uV=swkQhlOxW4Vui(?|Dkz%+fwa)XL}6)PrB z{dmm2+V@;-LMmyZj*%gS4?EZn+h1Jq?zXj`d4Xmk#QU#Slt`zWDhQi>*2+Vw9!^Wdynf^@i#wcR{zeba1c@A7yLztcJS z_0t%@0R`2(zv@@{Y?sfd1>fw-LH|0Bf0D_@N{VB`C*M#|)zFYeBLJaFpW99XREF*{ z>dW^$TuS~^CuLJBJtlq?;qcmY?(Amd2C+J$^&!a{i6imjUmFE$@;LUC5o{x>^Oq__ z#-S7n+4*l43r|imTWPQf&%*yWi@FG*5h%1PbMl@7>oDP?I@++=+0P%|XY;&25Skz& zRCGEmWi^K7DmzHVf(sa>;$^hWPV}nPy!4nzn;B2;u{azNpbIYTSEcSHQ2Al2j;pSP zmP^KNR`Su5OERJ$Ja&m2KGf$2RkOi!E>yq*8T0{ac!|2Yy4D|CWR;l@X331k#u7nC zpDze5ctxKX`HTf}*^I_{6ndebv<=yPvGG%|^6w8$^A= z1QW9`$fXE9iNirnMA|o!U6Kb~FlVVm{6{wFwzQRA5B#RIx|etDfOmgq_9L1_HHrmv zh;APgv79p(tucS`+Gsq$bL5Tl>Ty|197?HeR5>zT>@I8h&pe@wx$aI^y%&s=-PFxL zSDuW`$T3FOL-1F8_L*n~-pWbTk}0k_$Re~>GeLJ*uSu;pgm6+DABu!ehufXFlu%_9 zDN7@ur@p{n0yqU60P(LviEmn3DT?rKn&sO|HQh9Y;M#K)g!VWF%n$nmy7Wjd;XIFaK07 zVIuJNr!%AktiA%!*m2yif=hMk(Y`ly7r=KBewd%74GCcm-kuL1)-ZjtJN@Qv@GCc) z{ZCuWxrSi3=hVYwkRaw@iB}4mmfsn(REn`r#Qa}ziyvd&wF+qy&Gn+a z%Ey5^cyou1qT*2Q$D~FZ;uWd}+A-zlG#5-mtST`w-vuT7U*m6h&8g3+eOzQ^1}9US}t)7Y?;V zb-D+|QU^Q_GD+ZCL>`NvSQAa6Uad&dL{W!E#NjP6<|j`{C%EBQo=km~h`5ft6bvBs zjo8c5`7YScZaX-p)@$wj!*EodVPgXjI_;^2Tymh!???M|bfh%)OQ1GkP>x}WFdbWq zccpw>%xy)~Dn_p~O1zI{zam9#U(1K^$xP}bJl?d*=LAZ&iel#GsbYow?D9rmrH-DF zyQrhQ872jGn^>XVY@-DEt|1q19G@O9_FTBu@EJlD$2Ru2zDclRUM7dEF8L^Tcz`H7 zc@AYDunjoN%%5ryb<0|-K?YmkuUzQbK6a*Z76ndA9ri={r#~8Zt(I6w3cpId@51SS z>GO(IU-9U_VkzbSilxe^NfPV^2Z*uTEE3i`t8eP1P$g8D)z}0?)bnP}0`LS4V;{nV zghGnfNR5Pt+u~A{+_Sk%o-Lw*a;prP^3V~A`<88tlGB>4V^3{ZF&LVx*m@A&HU~t} zl(gF(>36n;WL8EzvFn0U+RgIjGglN5gYvzKrkfDsVnL=3Vw@$ zyaI9#otINCcE@h%<4RP|5zbgC^>^6lF}ghbx@ZcbyKR5}seM7X!_PO0$16;v!pNMd z0OO|8Fd6VEU0J2yh>=w4_i!Slxr@|%kV$x-=;-NtO24^Zhgb!^Ay2>#(T4uxr=?1Zn9m>F!n?Iz4p4-y>>z~6ywvEL9>sgL@JF(MVJHb z9zpN$({_7qfF!0Mio|`XTmg{^^1F}**;Y_hbvXr+3M5-7i%}B-NM+N95QOqcO68`?~^YTKcgeTsePMB zaZ%6CAr>jB(H;a33#g)IdJWO`iqA?x>v0vji!i{BLFJRnV(i197AzRZuvFUlkSlfY zCFQaS_fBk@3Gewli-5mI&xS#L$U_@L{dyK3PKZo89E-Z3_F%y)hYWtZQ!4 zq(2HSnyTWPE8%Q75;ZMjO~W`RKHUAGYhmqC8h;-DqTcYnGZ#-5D!s=#H2^&kTOE%D zr$+OxU?et^UN>M<;T8~5e|vdV7k>)n#}9tjMu^=k`bF)@<3ZLk&XHgA!DM{N3vI5` z?0>~m#}1l6*)X9CJ1zV?hbF(gvpNA?{-v|A(RE^fp}NXm5Q6k4nmkh0o9j7ffiD9&5=3G)QO1tmq%y zR(|s+?D(q!j*ZfDC!!>#A7(P~BRDsm?eTpS`DO4s`o`ot?43oE5%OLWEotLe(_Hz< zhm|w4h%GJ9??bW$ho9gRg|E!VTgRTF03((spsM1xDXe7ouU-~LcAx0xItbW_sGo15 zw1xXDmui$bNfW&HW(OiaqQU%OtFY%|)Ngv#h*slXr4%@Qw#Z&5`2(#o(-}`N72}wUlW0xtN_QLSvMY&~IrsPG+9Dlzy zbi9(d?cL#`9{u^%_=mV>mC)XR>x-L<=1m9vw~KD*=i95km`>^S7#O1ZG?TxEZf~2U zZ|*i^G9Z0raDUlx7!`$0w{ zPrTuIQ|IU0m(#xj>*lnlqIdB{a*#V3aN$8eZ}DX3mvid7^`pUgzT~O141hlzJ@;R< zuMd+LMtmPLNae{pW^F*E3THpM=ZGClN7$}@-wzZzs$%kY7wxDMyyrK40|3OXn#;hi zo~8g~lUTLr@xY(;*blh+wBYfKMgi+@!fVi$8&Z94#kFTHJM^?#HO8A7S>QFKa>o@3fD)@4t_+B;zcZ)Rs0oZe z7OX^GE9xC0Y6?X85qp%g7+(QE#VXC8>(Nx33Qqoe^m0M_LCL!2Q(3CtH`beD&qwA1 zpI7pnZA}o!RpsEwFVztE=VZlB)3gaSKkS5)ZF;i1s2u*n=RY?LW;@$9E0eHBFACLw zEuZmDijHa!);x;1wP>q~sO~KcpZ+wIS>5x?2x@!#C24|DOeaotnx4k}FC_woM3U7t z;1AO*sE(O95wRm@`LUq*T?(D6;UWW7iV}=HLsNM*Cc5^WimJpS_*Y8t9`Po~%kRKL z56>+lG&MFpqA-kg4G&!#9*_0ze8KX;blKdO>3kO7^&9se>Ks&b1Os{(qlZ=G4wq{~ z1F05WKl_NR(5Krb{gjojyrO8|CI7VDB>B;V`K;dUXG`sITjwjx{#^gW=#}Gx;-{s$$O=VoIJsupJ;IXg|CT}naS3%dTmf#!iYCU>sh-g#lJNBgW%GIMLWDqotX z7+e8t+Jckz>elXEM>Wb()I+$h{Jh`uo%Y-;Kb@UubWMZEeFaZ%T7FD;lyYpb{92Kl zWb4lLx#_m2GW`@4Vy)n-jeMas_kP!FYRFd|?nY?bzQ7skT<@C-Zu^&sgyA+&tB2>> z-0$g(53+bQEjK3S{j>0qDpAWqjJ#Np3kQKzSO2<5>DM|y3;SDEsf{vU(e%>?AC6bw zs0+`(xcw}5*N^G>Y4FwR!jtvJk+q+qmC|D=%Gi(7l~FnZ5^0D5jgA@a=#S|Cy z#BrlEW6M3G10V{74Hcq+s0}f4F1JY}sqoi+DNT!$*pV9GbCRu`bH7nWmf9A@@~b1| zBJa#RK{c66ju+*M8MSXp6%QR&{@i{Juu7zVBOUSmWpeYRWOp{eJcltBf`; z{C_S`gOhgCDn!(D+c=1Q8m9$5+4x1-s%&`caEaZNEN^O-0XobBHmDsB?f8kW`eY}Js%N4XyfBlV|`!?do#R}C#}YU)5OftOr& zVIe;2iJ@OE;pU9VT(l!8dRC0GZFJ39`N_V+KVU670=FSKgLohPi7q+Bwk9Wd*gLBW z45cc`?cy-77MVyZO5@E?bAV=dGhJ%;S2n7{Yka#SHjCzwj~I&IiSIQ*T@2na+f@8 zH^1@rf~0PHTMPdwg7&_aI|0==<5=`hl|Tr|2oMHYaHutaUyDwid7Mw;<;<~#$!$K_ z0D=a=C!5b$!dBPaM9~cV*~zc>hbhKUZxnE2S#C5i=VQOLF|YP*b@Tn$zpO1S z7QZsE@}S7%&QA}~0e@(hd3t0)fMOeVIf_PctvsXsuk2-1Odb8kV!O&f4B3hU>NzvAy7!m?EajfvlIXR zu&m|hEsxq~G$~)d8>)U{CAF8XIhfE?yM|rP2`K)Qz&(wsKLe;4|7jKlJTOK3H_(27 z0|A;#bnlwa#)k_v-o_7#pumOS*g?-CR=S^_J@s7+P_b>Wlr`T2%A+|nooA}9p*iHT zXP<8S1uw&xRA!5x)5;}BjtyuW9hqK<&&(*x7T7VK=YTEY&A{SC>N3jQ>y#M1+T_2$ zQ|BfY(Z5MNWGhriqAHY~2{tGN#6#vdQaE_L@=kZ;_ZtvsEU(}vZwOtUbDjs10?kiO zWFh8nL{^Ul-e4pZInFF|g>r;r4+N-S4a}bVV?1}@yt9ZfI+~ag_a((a7D5uGs5}Lr z2@N3@cc{YdFWnfK5e^^A2>(Dsu-6z9-VaYx3q#P-%YhDxv0@27(SsR z%~}KJZzVT$fBr#aTDH|>wr}TRQ>{6Acv0?tDAN}~j z8LM#>&}pAJsCUFekxk34J^qTdGHhvz284Y4hy^|AkaN))R87?k-{9TRG|h7A|7e;( z=9#h8imdi;jT>Bag4ym=;c;Y--epVY7vqTq7y%|ryZXE|_#!iBeaZ10eZf1?Ty}f( zKn-P9?@h&#*;!HTP9!2p^7IkMeycH-l9jN^4Y$F#@*9kDF z&`_M-btH>tTh25tdF zl*(2!sIcE&AjED3SX^hpJDojQsvmlPQM!1bIgK4$ z^XV8GWUyyTU;GJI1?iWTUpKVpc(;iTa~wodi@(@W(Lb+$lz+YwPbmrtI%ZZW;`mMt z{-OTK^-Z7|lgZpk90?8m;9{FBOroZ)~cblH7 zs(~-AShD1sQCg0Q1Q`COs*sJ>m771Ctsh=@zAoGo_=w^i7kb?r;@O6k*Uy{L{qRzr zT)?iPp99#?zQNq`!vmTD{?}Ow%vL0cQI@vnUuT{R&APl4Ox@5RYD4O6@2n;8$KcB& zK-ssBrOP{WKY-2}^z`&puuXjVd25|sqoVmTykJ8=+aSf-z!Jw{l(h`HRTwG=@3%1+ z)_O`iyWVFb+*mrQSQ8#vpmzcqE>EwC^LF0G2c48NQOEJW0P{T?Z+nFJ*N_X0+mP{e<7|3?UJ*2zTow3z&o%5c*O^iK&j|iT2>&h(nHR?H>BqWf=zi5<%A*B&gfQ9B_45rx&K@`rWX;=d<7~6fK zr;a~!=N^1pHZ0cn)%;M8A!FAIMC7%S_c z<4k<<`DF7_Nw&XyCKNrr24wm0GnS2mPlYkanLW-cYQn@zu*g`^dS6M2Gj6DCc%Vfa z{$6K`rZJL`1gJFXyAXT?@j}FzyczHRll@7TjxP}RzZeXB#XozPCDwE>oP7QX@WB|V1F=NXNH**QTk34k61F|2WuS#34TR{T~VW9nB77^ zl!M6iFXG2ztRZ~?7C4|VOYQm-p+&HP_{8y`vTJ?vK#p!0UhxUPrzqw4=4OZC%T5!j zsm*4Au^z9555G-6AXD6MMWvAB*iSY29|C<%{xt+H+;#!SQBuyzYXHJ)N=8Ph3G@R( zrvfNUMeXw`6iR&*<#}n0!ncv7pHWd4;K~&CPdZQoCamsgniq1?v<0<~8*FM(RKX1{ z?>ru_!c_>P(^Zy0Z}2$r61#Sxi3_hUX=#KXy_YFeLE6ZmV zyJr&7G$#+VwG**`Sct9=T#tG&on+3834kQboeUjC1aYO>t+2KGiZOa-NHim+`m{lV z8Tn?JdJool)JhEa-hX@c6eO531XOEUwCNMlh9}I2Z|geA?oKNHjfF3i(~tf$ zvz7}d;te61a>OW{fJ~?!Rm|-HrJ1@u^3_=99R3V9~*kihc6eJ^}%dn?w5&#FD}099n1Rq*f8TIjFLMYdsj=XtpZTs zLQh&$x2wc?dM$QnwpYEE!|_2!gTcG>nh?Jr_dj<|v+E5nm(zH$NW&V-_Nh%joLUE1 zyto)1%IgP(|Hy2)!vB(~3`OBPTVLwHW*cYK!eUrgvda774dIYl*iGoPz~ufig8kCI zPJiKZT>|#eCUMz4B?O(w|8sQ8mfqKSiG7#d$>dOcqyi|h+&n3T#rc(!Kjiv%^~X+v z^=#-vDcn{T6x~jI;0NoQBc_K)MJ$Opl#pG#$QC(^27y_c@wHdbLB&C@vSe76iJ19N z^PpnTdRx#i&g;S9FZ{)Dr64ee!LG*h!HKB>9orHF-RHjK;gVgA%0sP!pOkQ~F-}~( z?({J?>*{=({#GH_=LH@vuH=T|czem>^SV#rHU>{J-=_a~-At%R7{dqoX`mB6E>zF= zK;rL>f>etfq-ZK;O?>!n)LrGBK*Fk1x0fTs^*7mJSt@}5gB7LsDgzi|W$Qn05rKtm zosj2P#mHlN^S^Mo6I^!nHrf>OH+ctq`1qAl_1bgFz>k0Oya@0rdJ=N_^v&__Ko|(+ zv0`}Nu7O_b$z#QaPrF)rnSanNAf5lw)0p#hZ+!ZWvO^4+M8bd>j?P{I&XWIr`u9#{y@;S^QmDdC#t7X{P zx}m2^2m%FyDh{dWDXSvyg7q?i6fbc*c@R(Oh5sSImYXf$8};7My35+;!>STxJwXVxLty`Bxtgo5x+e2BKob_%-GX4Fhw zDo}id~WLWp_e%<)=iPFWNzdC?{Bcm`R7qCXUy6Yjg-BYG}z0$w4Aa z?HBDzCQ9OOL|&k01yRE;OaYXQG8#}u+=Dug7Z`;RNm6;WmEu9G8cNs$sq@x(upLD@ z60ff?!Vsh!jNCJvYNvl9v1z|{8KEt~QJ?y`H;c6ra9Lpl56;QSF#-&P16=m~ki2qk zBIDYv_k+q$?4JQO{eT=l>mzh;edS zXNVd{w)^Z|spPT!Ec^eu1VlR%)4e8)8O+`Hz8frv9w1v{k=KB}N2|rkGjf`oUe$AE zXSTGp2)^WX9puh5Lo@zn^8DXTg7;hW;|uQfvKd6p1;0*vzX?tP*lRNtwG{u_eDOrr!dQuZP{;of5yAw@AYlnUfc_hX@Q1>hi!*wF0 zi)6Z#Qszvrmr6*V50J?jc``d*$QE=gqi3MA`Wh5CcIV|lUio0* zX$Tkd&La(0ZAfV?+dz$n74k@zW%Y}D-5V$_ASv`S zT^bXvqubN`s%Z%qy$?1tybFF!*qQd@p@BTPY0_%rJ(t+Jw8jz>~fLLk$B|p4Z>BhSnfm~upzDeJ~-Q_eZCUT z%Q7c+N!tQTFC}Vje*Le_rb*N>@ZP(h_e6Mbp`oFD2V9LIY;1qXJIF(AvM~wsFVc&| zJI`d2B)P=7kohjLKF&!cY1R0%CpDn=?;5kThpQtxt`2PeLoSZ23y@A91L@??r!#*f z=a3#){;n1u=PSWrQq;GVB;2?Xd5*z}3Rsx_BMBv*}t3Y0U zz8jFuMmPb>n441rb>3RTTYo4tnD(RC-h?uk0~2!DtqY$8+7zc#dgBFRB*HX-1ls3n z`A}IJ(UyaT1#A+MDBu&wuP;uM7vd?OBPuwda#MeJs$I^T#}wj35b>~5S&fhJ<5@3a zi>Y06d8+NV9nBPRxA;XX5IYeskE4#uO7v)HJF6%0j|?Gr*dJAO19xFezw3mq*mwNM zuTVgppY8xi>l5-Ea9YN-;MbC<24f`5Z9E!!x3&S|`KwWu8V4_Qw5bt!t2D%Y=12ay zNp9SpMW8-{>y_&;H&rL)v&E=SWfzcX=K>&)ff%ddx~ z&qr5V>6Po~RRED0Rh_g%8>!daKkQY%&O7V=(pcbO#KNABu=tpter1y$v3R@Lm4_9xqry(!vIhtGLbZ;r!`^ zf!;%)miVr{nc)kjn-!L+NoP#n1J%&=i2II4_=?DWvy=~geObkY6Z7deRG=FL%*=t0NiV6m~gRC{< zmWFxWz8lq}uoaOfN@}#GX)wc|nSaW9U@$`|Y2$c*YZUjsrckZTX!5MzAQSJ?18lr;sjYF3P&`Nw?Z(zD0ntBKk9W=bfa&WXldVd5p?t{AICpBs0 zRuq<`UF+%cWmW!7ltg3f;LuRUZOgwlAul-~7{P32xIGX05<2v(oOyn3{3r$T&`Y*u z9+;nkafDzC#=RC>kJj~pok1X@;8MXxF+xNj`pD(tRGZ*^_p3(42nE{Gd&birKuuiz z5KY_?HnKv+sw7jC)lQMC)B#1!H@-CZON4<)E-vwL(AYLcOa$YzO?p zZJkF&qg9#W^u(@8e$(gn58B1e;(x$vp7+}Jc7!5(bAd8}+kQBwJP4x}B|$uNSjTX% zsU9+`{_sJ#EDaI0e9f$!yUBjf5T3f~&e?12CYKw3NQRFHK?{KkF15xlQ7xhA7!9uy z;f&p-O@r~z9YlLpe>x7wOA|P* zjKy_ECia-DonE0STCyZ^*@kISySCqZ#hStn%KWOh?F2Tk6b$|6lacS$Orda1n}?&Z z)BM(Js>JMb38$AwsQGRb-bd8BMCj*or~7Vt^}GZ~AAAXgnB;UM+j7;QrKtsC141lh z5-D#Q;Mzhq#!od58V|qJ{3zG271x~VDMi2tW(U!w<)rU_uLRB*b-DPtL&WcxW^i!T z3%ic!eRtCDD;-{Pxas)|}=M2V1%ew3{SB zfP&k@+3We`xHbG@1Ht-=7k+ecduXQkv26y?n*Q`T&w128w((=3HdlHjNs^*Y{#_~{ zd}$QE->4nj+_?TCQt$2kE~m!0p6MVb0jj7L3LI>i0YY>8bPrcxOu^Lue;|5EP#8DW zc*gLKm<45=Y>$`eI+a~1#SW~bUm+Bc2>IL{MMR!!;YS0UHItpfHOvapJ!fX*cxMlBk!4QT1flgo`6k z*%XO{YM(b9GJ}PmVlo2)tkwR}OL~3u9j3R!>o@bdKo2c-()fmMRl(b1TG1dLn5Ii1 zqa8Q=I+NN{7PB<2GPL=CJq73uVN_%Vn2ptaca}W_#m2X>&cmSglowa3QUma(2L7K5 z5C{T|oYC_QjRmN|?7)O$y>G*{)+}ubEvTC}&H9?I=R5alM@@r9-odEvlayH0en0ad;v7=KUAPhsVY@2zGYBxumv!u0I%b)eG7aEZZ^v~jOtDY*rC z#t88&@BThZ!53nAQ}U2*-n#AY(tgj2OVJ1_Ff4S+gkK7!Q4i!#_tfri;<; z$$G(g#aMp`SZ=EO8>)SA+!tksll8rfxBMdgmIqaVL4ypM5qBg#dGFYS(PqPLFJ&4$ zanop!%^}zM80#nJU>369LTTyxTnVKTR^kXTQS(WYuj=B;<7+X*9l`$I5vRVTd?;^& ziIn(xKaN*itrn!S7i@f8 z_XV+X517XnIKR04;e_1z(5JlG>Pfi{OF8tlJOY^Xd_O|M@zUp3t2F~q@uUXn69cV- zJaw%54vsy&y&by;^b>v$^zT5nI`_NDJzBo^%XLh48`!TZDA^B>f2oXAo~fN60KG6D zvI4nu&cp~>*)!q;ff9X$Mb%(+&!l#-2EqyK%icim$B%}qD^F->GS!q!L`fyWgaj8~ zeA1{9!v}0h&k`G3G zQ0qlp8=>$^l&VhY=r?Vu(?7e|0dkF4Jeefmb@qh9mqiQ#$c* zR}%u#=va^cx*DQhcY80&AFlc{6dpD`TDpgr3I`R@ND6TV^cT2*5!o&qL*;>F%@@nb zkF!bkZP`v~G5Hk^*Tnji3|fy!*atjIPABKwJTJJU+X=SM`j-XbP9F8!e#8Zc(nG;Y z4@1+Oh_CP&sU@O$7J0Ij!iw1z{#}F36ZOoDa}G?SrIqxRPOU0QHBS1 zF?k#y6<3jPPgX=EE$Y-!qU=X1BQ+F9Fsc#p5*`;zs=4GFSk*0^QlS^(;>NbUvU!-<_`ej77 zF@#{VN;s`w(JmJ)Xj5yn=OCP;?<`k@qH0MWFnxP8cAtMX>I?wO zCEaZcPC)?DVY`6BwhE~p)eN#u&7Sr>kXv3OYO!P+h8g&(r^binvXARIRQW$W|K4Zv zMgpt%$Dow22-Z1BHvoH{W)3nUbI8@`lUY}Sntv?FT01% zuG8juibf26alL~aJ4L2@>(&0}daNRD0m6Por(bn;Bsi6i`U%ZT4o)UN7)v^f=81(f z#ICMHvtOPEg9l%zTyr=emB=W^x@4J{=EPQD+uO(~QwN^B+z0Bq&@feyCdFX#XxTA+ zb-8dp&d~jW3Y$bdS?V2WG*%&=EE~7XOkB%Olg4`^?07uxahBV?*B7jwyRWePUp@U9 z2^a5Gx#V+*Zd>uM;1`Vt<`z6|<*hka6MOy1EKpG|cLwf+Zy- zA2Ub4bdy+_rH)l6Nvhu5}Bc-(|3|T$tUQ*X{^1d2Sfm zbl)Ax<)^{!w*xJJB3X~EpRonrqE{Ijc4qS^j@_eP^X3~A*a5LXcpyj1cf?5VGf5t_ zKh`>t59Mh%C!g9CIpS#8JBX{~RavMig82wHz-_RiVg_`hxui8>w(F3L-7^Sg zcz-eTnHgg*{X}b*6F5o&A-?=Y_Vy92JESIi_xQ_5cNc)iU4@-)A4^AQrJCqMYy`BQmu=d|U)Lq{zCBo)0Kx0UPjmZF(I~J{z$r!<|sdk01i1+dlnZy#1y6|H~PtpulIj=xyu51>hShBn>^lS`ec)%rW1 zt?C2S?XquVt38~u!a-l_^8qJ8c(P~3f~6sIR(K?o0=Sk)_7MM`>zy z`Zhv(Y9DB3@;HB%TNaP*uOG9u?&&0yoW1t@XEScTG0tApPQt1 z;<7A=;&VZU2cm@XT52NRN>78`m@^j98*Bw^!&aN^#_ea?9`v#s!>%r5E4Umo(*P6V zOIzkA)DAiNpQB3Px&g7J$Cg)X9K}&Cqq&wC{sgh8fUY?26LdJIcxw$aVKSCI#=ok081o5$E;!@uyMBDXTUcB3{?1^^d zvnESP;SU-#%z!v)uMJnH+)oz~zV9@xxRDzdGX*fkleCrRk54~gtIDGm2p}9VyzeJt>*GSdo{h>kVcC7 zS`=6^D-lcP-S~RKZR~ddodHsGAM5M2fLiV)AwSoJigi~nGtJHyNwzfa9uJg$6UBRd z5v+6o&XL*f8V?2=9R4?NR?l%PG8LOo>o#xQj!^OdibOF+hR@@$S6A63dq4lj zY9m4_mAhDe6^JTjvGR1U_ho7oU`6x?NV(=8t#8Y>*f~*|1t``R5Tj|DEtkU&d^AK z+?7K5zqB3)$$QXLMFQCIUA5OC-5OdT#&D!5H`IV`=_HE)lz^)?ta)alO*UxUuZnT?OAO?e7X+y|( zxMhWR#q@O^+S{BPsM3VKlxbNvs7AuNX1#A&l-<3ye$kQFs0Qp4SnG7V38*LO=(6R5 zWXMhTGkIUMD+9OV1ekQPJOLZVqm|+7C~|kh8Y=%FZrt`#n8g^#e5DjoBZEJH*4GWB z0&3Df*O~Dfk@^JyJ$SAabl{O(ZT%foF#aW=_Zm2?nrdXZ z8TCwR?rbISUZ1i;5{X)k4_kv7|4c!K^{;24WAX#LX_8is?x^J!Wal=WDS35iP4v^t znu9B%giKs~bAccA4lcRIvLF&lYp>*96dknMB?{-9`EE`ylNs*_B1$!&?8pjMYH_R{ zRCiS}4q?+E87C98(ycH79wm)jEl>6l)nY1XCnt6xN6tI9+D)iFz&l2pgnj=KW@j%B z)R)30Kn(z*_HRnrownRprxU{3KS)*o9-9n-re0nvy=}2YcmWSruCV5U{`D+OJmOW&LcACysO%lTX~l zj4~}8W|NksyngRhmr@a=N6gT&zgVI7)g%8?siBPN@VO3`6D3pKa8=Nx&OWCrN(e~H zi-w+_g&-BR6vHcd zf0&WZ$-bg_;>z6QwN~p<*IW|sON!1KUqpQ}tffUh0WTbt$1(`WL3<880YnM;RCGuz zMR4S#5)(cdMRj_=3a|+u>R@dA8E1JZf^2#`{-FduL&H&scH%7XNCe^UBIhhg0h&H8 zhq9<$fjuDBl#@1WQbpb+%Y$D&Lv@uU+1DN}N#zB2F}44(DPkx%HpgzI-n@JBDhe7xm^Oq|bkz6NnJcQ#OXs&B>Uh|VWSN?8V>VltBvXJy z8w|cjj70TPL`U8l=OxD=#@RhuAQy%M2JqYUp$+VXMy^u1LsbSqW&*UR_MVY1S6BfR zM`Msfo#v5!6@W|aF1!>7)eN*E0qirEPcq@b?27sQr)m9OnRMc1K za;^pnb%M*V#+ZE}FF!6Fm=2L-6=uN)^{zI36|u(8bvEWEK?Z*xvK-c?s^g!#;KR{=54m%#Ib-X-QnrDq9g z!Yl2vNwgze(cVt{8^gn|C2gs;f2k-fy0DT_#Ml?po4Y&2I*62vF{P@@3nxBMWWmft z*5guLsy&Z;zCu7m7p!SeRo~EEH>eE}Ohpo|nprc~Gk4jzX^?}!GAR*ImKKMe`S8b|R zf5Fi!1@O8~^te|<$U9rP#3Ed?apdiHkU41or!k&-c0@*lb* z6O~QR%;g;bK9t=BC#9djY?*bS?&*2pWgByWBSI9S9R7Mu24OI5uRFo*i@|jKS!!-e zmNJ--(btZAS4rwSFbfc^rHY-9ZfB~U&}_Y*c{?5E=*SoQ)r6r$sNG8%XRnxZct`LL zfFm<0iXgeTT&?}(VJ$2AV6(-;g`DeIfIdCCSHOc)YA3c*IT(=SK{c0e5PaVHDLg#C zq~ts|Td1qY)_m_-Atl4Z_wd_&uOdmpZs^nGWlP02_XGQ)WTa2i$GskzA)^pJ0$Buc z3A8+Z>nJjx)alzFRc^oDhk!JvpoVuweR%|CcYp8h3b)Bl_8Q85{XERB{$HVVI(tB{ zs>6!zf4_IIaE^Opd>dx)?9ayo3ht4ko+pIUivRvibJVhoP)Gl1FzPF_7F=D-rhh6- z;7tMAjy-{U= zzjqRf%ckWq!=wnYP8lQb1Ai}ch%gDh5dsL-X<^`Yns+Vuk`Q@AJbDj;G{k69KUe#2 zhMQK)DFqRy@KUBjYM$A%x0o=btBnknbWgmuIZzSiIVO&gaIGdDNdPWQ(r>YVcyjU* z3yvA*`!-byVe^V`Tm-{oiI!MX;(&p(CoJBd{*(`_?<9K6HF8qrI7g@e;2-_p9lSxEzrdCLaZGR@y^vn{xb(}m;9qWb4mu^ z@e;D_LxjJ?Kka&`vRQIRSUoBL|)cn&GRJU5bp1CFe?O+4< zk5b z5iU~0YVWEjD{1U^>fp5LojBKll^7UbT@agtxdVOVI$L%wdEX0%R_@`ZQOd1mCa@a@ z^o<7Aa1pxJ_;RFwe~ZEzS*s3h5$D59qZUmhdnW-QcB5>+=a`U6{Zs8?wS&og7SI0m zGe3;%#1P~VHei~9a636VTON0sw8KE8*tzjy-%xvC_)L%8&@3NdHwFkKVJN8GN$v2{ zN4sp!Zz4wl<)!zRYSc7h!^p)&%QzDSuVQthLTIK?7q(;=_3LxrUL=Ti$Xm!Gx==d~ z3qT>`0YZ4Gz{G=PEe5rBq1egbD`h%`N^@`9gMY}}A$yq32oKZ6J|4c%2ck!FXjzKT& zLVa&BbP1UcE@(FP?-vBty2>sN+jI7J@9LL+-i}FNU~}@~c0mB44~NuX!3`KpP@?S7 zXJKP$uZl>RMytDre^A9h1@~N_skQ^`6d0T_OxfkT8`966ey69vlKN^ibS?db`?H?Z zAOUjoch5K4fp##dPZ{eV#tdt|4DI-fbsjNt z`$xDWRq-aHj&CNjO6jLF7_SiC!7uf7>=v7(_DI;?3|)9XIsSP*h%xJ7sBGe zNtKA?XW>Tfj7gdNv?R#GLeDrXU<@u=5DLyvnLtlQtc=&8D*YDfmEUqbTuF#!I5AAVW1#_5h0!l@CfJ{1wbN1(+Qn`N)k?u;w6Kj!r-Bd>B{y;>mWcTbx; zq0WF{cn4yo+yk9cm0X$eqe%jitwKVYq&;xoq>S5lwTwZTd*M;XcG`V*u2x1K;9Lh8 z-!v^PUkNAPKUp{!z1A;k8$;4fVb(IlUe-+Iq0Z3{7%c?bz9by}!s7Fly**=$LYI-D zrJ>q;-r3)C1`A$$M#Y;xUijfL=#ry1539G;fPFc0(S;ASpZIIEhOAHv*$WW*@*1~g zR?Fe;yh8%K*ID(BOIP}86wJF)gy7L>Orb7+90$;_TRjuo|I~Ybyf=TgyI{f3cO0p9I3%^->Mn}U1#_ab4VmNEm1RUT||zi$Fba+7Y)lC zBhD|=i`9njj8#0$zTpgD6#~~($j05$t(_3+sE79bmhlGBpZqX*ieFoyH^Tx-UbIAz zDBNr{%SSS4ZQD^bsq@8dc;1HZi6>fgsjn+Ji(g`kB+CjN4rc`=ik$OtTOr_f#;_+s zwto3@Cj{_F0mOd)n_3MQm&rp>^%TuI`G|c-HV@a^0SkHPIE$J?o-zfl`#O$kJ&bcb zGsMF$*4(D49c@l8=wEuPJpsrAkG}mbXdHdJj%%5?Q=b!b5D*;uCwZm& zL&AyN#Q)%N5xt7KAw2b0_W!5@6;C2R@NZ>F>;0))-aWiH-HV7O zk{e(@nzhXQvkdRCIFy@&NP9N2<|A_GPaE^=mQo%k(m%_75hde~oHG3) zBi$TGoF+bb{wXTj)Tf=QO$Te#MF$Algt+&?Nm5Lz)DIBkLlu`&X&bw;yEPU=XR_#*{6l)gj>%O$%%Mj zZeK{mtqUg(R6{2SEVGNF4&-4C>3^jGq}vXz?Xt7x)@SB!yLxfgd)Za`h5&BiYr1uNFlwc~H|}gQ}K);av(O)AK&~rTmLK zPQk8>yZS*eZA8lm8sQxmQ)-drec)BlU5+O8;_gYTPWuF_JCQ>oPzQ&SBR)= zpe-q6eD9R7f=7sHYfhR1Fst~YN^=If0nq3lSaXD+AKeyn&K#4FA!i+koa>qd>2DOv zUuLI({vAyBd~YD<>vK?{Vgfa`fi*w>`P;!Fw7#=Y#zzx4V{XaWYzSJ02BeKYCoX_$ zh+HMx!VF(`F^OdLyH6S0N$jC%q2{rMo^>${%j)|Up-KINR;1$Kb2+i={=ppu0n2*p zV4L|72tl9)Ay00CaZE{Nb&i4pku$99wzf5LY45&!7QTlh& zz-83fNFu}6{yo32-|sh(tqP0^P-0qUdUr+>q+8!(IJ&mOkE_($8~wBz2CNI10ra<| zu1nSCAn3_dv?BvmuJSq2}*P)r|}iH9sBjhzW}PDjKSY z`Ls+tjJf!oC1-f6SH*-7hAK~SF7~wGX1xbC{W7urW1}k^)|QP|BxlxieyaED2vxm1 zOs4aTYp7%~*`k5iT>MiphLtpuYPNd#z@V}_AyI-+DRb*}lQB#6DH_7ULf^5KUoIDM<&CLTwHf9cAh5sBK#20e%^Y&28?&pO> z{&(z|xrHHfi%QWj@zSC%kchW@;klL+XU-qu$G=L)5)lY|rf}bhCZ^c~>4}x9Xp`>J z3#Ht#^ak_I7!oH4VKU#M%JV>}(}XtnCmXz{+SsYUq62gp;4S?EVY+j$xcg(){CzRa zg7P0j5a2YWx-7sADM%=;{tk=W2`P29n%^ zOd~<<8ybqCW1otE)Wk+fL?Yo$qK`$M<|sq9c;*5it)3^?0VKofvoNpV0(ydZg8OP= z(;jn{#Ws3%aKiC}Q%hpFc6kJ~gL}U|!p{-{EwTR=E1?XCb}7SSQGGFTGpp?}R0DNukXub>)DV$T?fH#!)plvGX;%h6UP^ZQ@kr3D>Ot!Xh9Rx9ne*`y-oa zpmr5kx^-bOGD%C>O^Y0xc`~ARFAKO)^1|0)Mt%~kzZqA`bm_zwC#_rz4LTP_;yU{>$hxem)ujw*l*k6g zA}`5j8B^?wIqhq)*5N87dn~b%laY9Oi)il!l+a_RI84b0?tqv1GfhN*XDD*0YM+4@ zt5O0g?NVjsMiE;q=T{%43*Q-+~Z5mKJ?PPDd=2Ju}C%0BR?EAN3 zW2(yZxl!9I9NU)29PL=9{t~A7|Fx_mbU{z>v!n?^=oy)Nu98Uu>QEw zzh0=oTY2&uIFjl3KN3yE0)S}7;Av3bvs9x=`e;FKDL_P8^n*1`Iae>uw3r_u07o=0 z%0Dm)GEh4A0sNI~*sMesAyk7%{Q17H)?WzXrOqb9x=>nlP(@4aO>31}wKp|WBGj%}eYZucMeR*(k(d!G_O2N# zB4()>t7b?_es}cqJkR&}{eIv3uec-U+~b_vy3X~I%V(g~x1Jb@z63lqH>l57 zga4qVlFzHZD*-YgVly?`uw+`1nv_bIXkE&piU0ADQM7VTctq>cdyzX{HVr;!fZq~U z-Z^fzZ58nuzyOV&nn<<&n;{PSC&O{%PtDGsxBTdVgah@dCBHYf6?4_8bWg3@5#y;= z;AIgE{@mBhjI?PDg<(0AKd4bN1%D_NW9i^1W$vkc#R0JLLsvs zUQ1$ey%-C4zzvG7)y{5hchB(pp-5;8`cB~o3P};C*Fg?IR-}+RaA9{@vP6c;rSs2{ z8Lz+3DH-4LJ4h|xe#PYB_@RhlJ@2$X&b9d`cBL#++Ux9)ap$+kcGtqDftgh>i+fhT z>_muMxLYmEtijU$G|CU?@D;DEE}&iB-%x!pQ-6z9t$A^w%IAs6wzxe&Mq<&6#QSuq zkM(6(F2{U*`+%564fa6m;E(O?ze2U9tl9x_RmW}jI?uOE((+e?#K`X7lGFjz=6#7Y zAifIPex~D*Re3(1fI?nYeg?=KdH|Hwq%<~6RTUII;mQP=KK^+8A z0bfLToFBh=^Y{;zxfvDO55yQ5<-9Cb1-Na=;ECv02$6Xd^Vf#b33o$(vXI>M!h{g` z`qD^3+xqw*!NyelY%}2fiMYeJ z#~nB3{>Hw`X~7GhR&~9L*q&b7RL=dCo3wR6zfMVo0}88&of{#!kKUI{PaVG5OVIjJ z2&4j$=`reOjcd!K^Dncex|~WaJ{}N2c!`d1^xR)dn;O#}B(|>sRe3kzQ|2V+w(E{B zV>O4^YJv@YVNSEjNP@m00myy*SjW%H`_#rJ3-?&vC73wnt7~C_s1i-5kI@V={t=&{ zv?m|lr<^Qwqv-JmHN9(LWqW_iU_K9g)pxQc{b&M|A1ci8)7vl5!@m)vxqrqOmpGok zqY5!q#k37SbpR`*{>P-YE!R_#(fp@8Ls|x>IlB~H=QdZ#I_?py`mbUv=Vs-%$X_mZ%PV~r{b`hm&1&-`H@m| zZ=^_G{{6Mkan;Cn`d@`*fb%Qa;3-}-+)E;75ExM(2!;#GfqA&E+bV%rUQuHCGMUZ) z8BAp~KrceH*n@&CxV`fvr|LlS)5pRII!4Asg;fIKH|2PS(wb-;#EVlY6`use=8_oP`;(WyWvRVyG*o5DJ|%>{D28r&AOLVcPy=Yz4pJP;N=649?>azxN_*d zlr1UnG1K^aJJScLLK56(#X|3ZPh#BP@S$w79Seo>_Hf=kuK)FBc^>2-N4$YeZ%_>T7IR2Q`TC{4~-xKkN7O z#)?r0pv(9%Rj8XYe>dRIR_95HT%f$lj~75GdPQaBGq$$2^Q()${kKX5f$cZHEC#;s!@mKqr1DFa8HUQO?8UYQ(+I(7a9KBoZl?~tBZ zX;2UPOfSloe%6Z7n9lQ3?Otd!@*NDP>WcE6e<84E_Vr(VDrxECio2|P?G?_s?G2r( zSyK%tnoZmBX2YT~=Nzcil&iH&asHN%KVOCA`?`&Zw~mvI!Sm@!%d@g17uRd<1>^&& zN;*oplPIM5Z!zMo zDCD>0at2Q)9i|;x75+%wGu`ptHI?tUVkE=A05W!^qvoFVNyeJD`{bhgwDSq)A%5pq z_FYAo#xe-fwW&eufI6nm!jH%R>(7wyC78LK?F+Flm_DaK~v=Ob-o zXBSvkWV%@0us+X#v9zVq$;9#dkMMPvcI%Gpc13A`Q4~J3RLp|{fV)jeouXem@tNjg zKyXCt`Za)&b56T~_UU<4{WC^GAbRz#!PVIq$g;V{fr@Hqc7dT<1yU*Bin?tkF8*(M0m7Pg} zOUW2Tp?jU;Q;o&z52$LEcFAAqsw0mp5FBd;tGrC(p5FDQjJu>~*UD#L+9RTADfSPZ zOfMfvXg8|1F7a>rWe#h40xzNg4eUQD6!hnfh2KKFuz|C>CD*-SrO&~xk0f88e>M#X z!fyPJ`pTHjdgQmb?$-Dd%{}Y3Sx4aaQ$zoET)AFoD|3}q6F_g?e$*_%cBKCvA+M@Z zV4|FHk#qk*CYDpvIBVu@#*NeuKq@T4Ay*J#3bc80%qPzj7+r(zvHq{DZhybvI|2b) z@&7Brx5}vT`Z#dONtKE{3RADBe1}I?$W!-)MX6y=g%Y+Rx{m6qNoMhX z6QEh+o#nVxCfwxaEI6z!j}?_WK~1B*M3F8&rMF4d4Y z_g&U)U9@V6Wo-owJe9gt`V%CtYdpKjfz0~NA* zQ&{1d!{v+gGUs^i_{qrgfD(ci}UU|JdzUGIV5zkD?iAuWshpheb z-u2623#s~-^~&g0xA%O+vkUY}aQ>GCzEu`prOJ9OGJK}@YSW=l@tE4aLGS~BUaK6w zYj@~6wpn!o^neNv^!1+svHnDTV#4Lid2)%D*HwVsNq+y9JQ;q#4MBj!F~jDMx12TQ zmA~tqfTDk)GX_rtb4` zmjr7qpR_OtRlb+qcw801@ndWpf0Ah~G})H}M3F8%1!DHuEQ=GR_+;r)^Ra7hvq*h& zm5^uN6xy8@n|_ZEPF5#Lrr0eD>U05)LQCMPbXcD28oA##xaNB*0cqn2Ns{SuQK27O%Jub!vdA@q407zyNU1|C1 z0s|tEA7}9&Y;Ei=uw6N#>>r<#FCsVW9L=!dn#3~1&i9KFYRw4pn{YxaB+A&}(%!z3HuI;y$(2t2b8>s)k0j~puYK^zFGuSSQB5_J7FO_Mi@;ri{#pgl#S)A4v$X#|Igc2ZnJwXD)uxC4Ww z%<2dAs^3#f(dS1wWEwg_-xE5DY3;R=8E1PCD@%oiD8 zD@Kp!WDd8)lzpeqU18m$3NSe^=2fR%$xm*b+HBLO{RxQ6OLG@J1O%sQofZ-TeXeXV zcwajs&%y}SFe>KenJ*ehS!>b0(BIG|;nyNW?UUxQ|M{3jlZyRl4+0mhWplJx@2Y}& zR1L9o=va)$TT16&C*Sn!7>Ao)K9~@MjYodxSBt&y?JE8ltlf_WSa}-(|Di8h6QJ$Rv2HpNUnDX+=?j;d_QXcL49;9!AZ$CUE7Ld^UX;^KcVw}U`@WmCWs@`PJj1$_?HOY zioiVl&nmr%d&%U#Lo81O)9}q;*K;drze+=kr#9X>MbeenbsrX38krn=ub?6O2sBC< z_^bo2UwLUzb?j9C=2db38YO%?{;64wTy}Z68tJ=VvX%ZZ&o;+De{X<3V~MhjD5*P& zG;O!_+6n=A=Vxns6VYLrmLui$>uf`;a^!dMToKFh8?Fq+fd-6drL1UuQundQ(2Huc zb+Rp;*A}f@s$^Sbk%p%|&z~F2nY{~(b$^jOst{e|kx2ux_o|%I~G0?!k@N0MeX$pAyweo9xF>ZKJC?aCP zT3G2Wzh-zOQlYE2EWx=G0imJMjAR{x9Oq~{C%4|2-d}_7c&QyOEGe>L7WPSHp?yG2 z&RSASX-$Ud{_*KFyXg|rZ{SsW>!hCo3TdiH~zsmw#p7nWG@_M z9Bu|E8LypHBAHEvc@PT{{CD$=7YC1Metf=t0Wem~CawK~1;?$u4#Ogng$7}>tNl9H zf{Di|8wZnD1CPjEOTzh_-XR7VEKDlFhd8qNt29h-P#%4&T5l*pQmFT7W zx^72$k8~>t&hLPth`Y>z-=U3*`o|T3b^M*$wFF5}IQo(>PUhQHBkBkflNU-Ut%BTE zB-+4@>D09Znnl5PT)^WuHO}AjZ!F3W7lH1F;B{h*T%&qxGnx`J{SCx)W^zh{OEt3W zJ>nJ;qJpg;8|gh9qm;%~5w`V1&pl?f7y(M7^-x2j2!GQD`4Yho#G*g`m=*Kj>ZaJ- zsNknFoU6DDGV{~lLlfCL6otmZDhws`LK;mk=nQqi^vqhb!eR{{h##O!8eu#FtMh|y z%Ox1f46RbGqWt#?vqt9zj15thl(C<=JOt{!|5CAWm!B@+M?e&-nAfafz2TA2)Zr;) zmRfx$MNJ`B;%eE;%Ur+^x47o#%u72gQecL_>mL~v=iszgE;M30N_jMA@6}$?`xm!3 zqK1BB(tH(cGDS7eI*s{H*z?xx&M`K=w1!hY>EAyi(#czOX?P)4niNsHd*C(+7Qeo^ z{`rVhTj5;Xd*NG9(Pq%0@7}H)MK@{+B(Bv~(rk~_gZ6PaCZaoQCw9Z@$rpjt#K0wZ zjh87VB!-;6upz!0Z}KAOfJh*#=LPxY$yDAL^2{_PK;4jFMkz9!*oX-3FRC}lEQRh5 zc#?XDyi#KbM}**swVt`_v)a`tjLp7j134s0+B;ouNsPAE)0vAqs6l~Xp|dD-aYVNp z&A56?&}7Mjf$SM6(&L>J+K_*AF1YYn6(X}tVrT$I*v;~9$ThYirx4`h8un)nLk<7s zg&)UY1;`bi&XPxwYl)|muAhvGn#bGW=-RM(c%A;}M`X0V_29)QD>dBtngBhma(0pd zA3~ilys0o+j7A#CfUeT>FPox*BebowM_FpVDG`$vY10QI4Z$OpzT!u0*0tgzHLU<_ z@0Q=s!MKiG0%ec!9PD;bMJ+Pw`OVXn-uwlf&uF z;=yx_L7MMjKAEFik5+{zOix8LT1j~S89S6JA75V?z86LDJ!%tGuTZ=je56GrjJ4 z+G>?Ef8e7^ZQ_hI>{p|V%f?da9_KOdpsRVs58ro8cLTG{DfSPBLB5fVJ`YiN z*CjI@bbto}c9)zHPE^H#I<9icbQ+L;kKr2K#2c_ORYc=!6C2|S`xSV5brdQA5y-m_ z*68HW=2(j;DaZUkS$&iOt+ZNmYE%b+5x$$H_xpWuV?o3&&57EWn@G&3!&2W(6TfW` zZ%x1&V@H1jWdG)1iB43Y8e))A%A<~&@j@Wv zut0srXl=EuJ44Bia&3qF(VYmnG{3pD)h<8Fn80Apo8QPh0hh1{Cz>s7GEF@jjA)pzFA?G zW9Ic2(l?6m4gjPBaW=Z@={FT)a~K^n>eu?a+Xn5}M0x5CT9DHE<*L38M4tz>`k(Z* z^QHpewEe!9))j(aQw3-SV(trABD1Y57r15clsp0OQBvjWuH@ z@gLz~Owa>~AVb!^t3fNqr#%uK*+_7OVHi{Jx8OuSTSG+MGYzrA;2)A(os}M+4ueiJ zy5Ya|nw#=283{-ekER+2I2nUAIeVnO)hw|ZY^hbBrR-LFl^^zyj2a@<>pSpnG3P-m5(CM8m!R1o4e6dC&vDE9f*!A@=61gE$Qfbs8QwWjg$k$r8 zM$%X$U-^_-}pc_5)}ird}>Ho|{nczthnQh_AoW+*#}uw0lK-aIP!`*=s@S7rufVJ$uW-=(Ijy znvN0iGuZ0(az9SIRMbjX20YcTspKkH8uSa?Gf$R#6C{1WB2DsjDC$p-d9=R% znLv@bCO)<89yseZ73`AQPC(f+q?1WRvHhHq-QP8)UOk30gbvim@Z*)n8i;8PV)u9i ztlBC2jo_oOjN$TFJf-QNflTI=(?{-QJU`4r9}+;Qo9R{ah0;XSv5;Gn{14Zo$PQe*F# zo*M4-T6z-_;W#jWI~HX3vQA^SH(a&z^gh*eS1~GgRn0Ll*~8Y1r1%ngO|-N{C!=Mx zA7y(@q=75JmltYq?>O6Hac0VaIoVvtH_qpmx|!`|RLn#rfA4s=iJy09bQ956I78$3 zaYbd`lW9Ik6LVbwaj<;_Vv=wSN|Ups;FFhOwSaHV;`IZ!A$@E&B=QL|d~3^P@8`8XqlNO1|Y-1R}~M*_q%HGZg*O zc(W|mcQUIb_jmi5GH;MSkV!iY)lT~&J>);v5UV7YjLh@^%p1jiFu(lPr!TyP7aKqc z?lTvcf)rM#69Xdsf*ol9aPCN=wEsBt#d;lEo_Tq^I%O`O9~KpHG=})+iTth_n!`di zzkXeB*q9hevF6)Bnb%lixa6fW@DwKFsALK6a%_zckxTft> zo6-Cn65LT_I#^QQSBlh`Ws5-WbF5Dn8L5D#)hZ<+jSsvqwt}XzR{_1yN%59wmtb8 zo~-fqfJI~{fy z#79>LQUU=cfe^kTP}M=(HHNg*y%!T@Sx z52Lf1xd|d#yd2egIauacBol3#2x}`PrAqJqI+jaOG<`sWV|~YUBj5MAO02e3zeurb z28U4B%J0sOw9{!IA4K>0SPy?;%SM3g$~#Od&=Lc;5B&_#w!3_z?RceZ!<-X4bC zUXlJPF;EUB+3#bLpug=L-*mCH82W(n0)`8dMRGJDVE_vzLID>g2OX}74wu9;$`_%O zrU*gY;GY&*JIs)L5X7^#kR?OTE`rx!|6|=&GOl^O@%_=7N0_Ykk2=@&3?9(S z{ky}chYh;-$n!?jB*$z8|Bul3<8y-2~_Ak|_H z19}LR!F#*n`7ZbB*%krkQJ_{1M~t8;<`v$`u;B&(F-kB%WppUBsUgOn z_zfGZvy)eelYx3#9=Oo$+IND+#q8JOOq34Nd^W5UN9!~CpgzCStJOqA!REr6ljVGV z5N@**m%RU0g`@}J!eK1gH?6BMIsTZnY-3M_y+W~beoJ1gFmNefy0Wi#Kw{S4Xx`r@ zXc~u(B*K~lr8@^s`0%8vn1!Cis3~CcSZQDf4ZNsdXUoh859fDl--mX$E|iFYAB?d< zBx|3sV0XvlMWbkIr&GL@1f^o{(gFK z!edZBUw63lF88zat%thm>K%rQ!Dvl8KPvq`jOc$X z^UySpT{`!oogEu85tLhC@idIR;o)#7(tij7@bkblz7T9nDORVTwp9SP+z7N!iR2&! zuE3YHi(qqKG6I{K(&pWd972Tv)*mu}ms?D;OZ2WNF~2!#AErLK02!#zVQ`*tSbD>9>2RbW ztN)BLKT0k}UMB?L@@YX+rgz61hUCBW(M6BCEE`RA^}xgvi4269g^TE`I!8c2imTxg ztd<-v+x$1o^28=1A`>xGtP#|V=+C{9PU;RyH}zLzxjPZxFK^^b4hD9PmaQ^gcOL3; zHBOD6*z3(gu{qDc?KT1)a12mt+AG<@`G2?9n+4Y**#L6>-VIZKfCuhsb68+r2Nw+_ zgRCE)G9ryz1wiY&*C2X$Qaz~%>q;@MXvw4#OJCEbm2@DE!b(o~`xTeh?3>93-TG9* zGvzxH$QPLT04csye^5D^daX3z_h4H>(pl@wfXbc4LnK>~ngyo5tF~<8mlL~Zffg_S z-p?HHHEVtYV_!Ey!`~4dK3juQX7lG^{n-00+IVD2E*BLgzf2chk<207@O&yc-g*9_ zF|c^Y^=kwa^#lsHse(TGnyU=)?ta6sCoI8NaT6KUOZxKs)z3u5nX$uN*Dsz7s&8r>D{@C`eZj(T zk>$P}X&GR>^>t7cJDfi&t-fKUAc8UW1O00y6}!f6KLZy#?P`eDj;==xT>^9AA67s) zRRnJhnfXi3w2A#^^5i@3heKw35=ZUnDJkJ|?+TM8tlSD@*ZjRhhx5R!d5MMKgGq!* zjpY?j0eDcHed%He;Vs0%1}tHb!;#`J7qkeVJXvz~w3@zFMSSgZh4CMQ91$M$hAhHM8T1 zsimROH`F_9D(KueXu|ByU6gYio@c)pte+Y1Gia*(p~$Yg<8^RiiZ;Qe$hcpH{a8Y9 zx!JxM0v@dryE$UHc9eghMEPNfs_QDu3;) z>8yHDpz!T(sb|~JV%CBFeCPA{(y2yO9!&mcJDyT}O4g$t)cSVK=YXZMe2Vq2-WN*( zPh72gf{NYKagP1N8$ALh8TRaMwfzcyy<)McJBYR9Z4WEE{q$%);puBMG$o8~794}s z)}+X)4;;egiwS$lz{7i)^@ErU<2o>Bu;V;flJF{8@H_DkFmELWwn z%pR^Do~C&nn8f&0F9ZXxsL(^w0^J?6va(`dJj_r~8?W~#jy3VuLyza3fG#^2ViuEz zMIIoZ0T%kLgZvqF;*>s&Tf#iQQ&K{6$mlY!ENIDIk{S8;d7CWQA}R|zmSP1*V1;<##G-;uR}5WzkUh-Q@&E`a7BAn} zi~ie;W6Bb{-|oM8oI-HmMAI5SLsgLkv;M=$+l_c}e^n+YSTu%kYQan~eR$g<0kl=Bq^O@?Tf4?vX0x#_Hd%ncq(;$ABy~j3(-q zwAc%p4ky>h0@+hs@n@@Hytf%LKWmY`=S1Ig-n>}2{tEssuU{Mj%77t@ zO$PfRKZ>&Rw!O zlR40_)K`90Be&RseJ|A`%z96Z-=y9g+AWnatN{Y6){cCwGEs({Lb~4?9G-2nlJnwV5K_%X7Qr$lr*=UQyti(n;_`r@b2cTUkTpMIAswRrs> z&f&2!T6QzA_-UHAt40mekN6mzm-HjH_fe~AMkc=?YePF-19t#ITmQC*{U;9Gzn5TJ zu=JH*hc~^-p137Hnb1Yuze&RJ#tmz9mWH+_%Q^f>^@R=IG{$^tMoi0EiTTK7N@onO z@>ti-9pXal7qq6wBZ|B%TfJ0de2b*ECR3}l#G7ieHU4q;gBv{%vy8xkyXgjkD2-zn zho3`C$bV?wwuezebU#ys>dos6&7#FVxjHSVVi!MLwZgh0de6%zloZBD$bYjJsXZ4} zZFCcE=`Bss2$~oMCFih~+sWlnSM2JTKp0)cd? zT?^jTT>_rpp~bpHNSMDw+_CSP^(#Lv$eqH{f;F{z>F>~oUC*kzLi1C);wON0!rsG3 zilZm0fpP%-enU-_@@UuaGXm*i)L{2;XE#0=04>~4*^g80Yukt{&%6j18i(cINV?m9 zM)sBX+BfDmZQbYpWwNp3&|Ok%P?+BC7c^Wa0N@u;w=wzt;I#q+c{u!QwU8wzuiXV5 z^tni;yO5&I7k=h#-f44$n|)x|?0cK^41*YZsHt~=wsobmVaUxmXs)q<)9npILm#3r z02QNYuX9P+^c5X}y|yb1?H-g{NOG;4EYQUoIr|gU#SH0Tft%$9Ngi9j?Z(~n6}5OU zgq1yqu43uBdUJ0OFk*W`l;lxvCb3KvZM!om$8bKNAGY+t;~77-#?n&4WY>MeG(RK3 z?^jc^_8H8o2&Qt-=D<2>2YXAEiqNV z-sX13Zno8%ea*SmujpFqtRE6IG&l*n^d^~FfJ-2+?QRaBX5Q1BNAkcjiI^|m0E_#5Li8Q4$0pqUY(w#Cn zpeZMPT>(OpCvrTs!4#kY(4|MDaQX`_nIadYU+Vc)CyZ)uLH`cJh8Z_JBfM|~Z`5^SVirA%*`(HD< zZX)b?sZ795;B%wpIrvC=$kilN6yYh+sdvlveW^|f5!24HyOu0#gMs)uX|;dtN4t*J zP<$XJJId0UH#@u6uS7(sAQi=EXkM=$U@u1&YW30G2VXYCfxq#_6f}7OCJ~#j9c@T_ z^+YRr?Jj0?i-a|th}GwD;;V=LVR$xzE!_2kGrrmzJgqb#>?~pk5BkOn4|;(v(5dLx z1B@(oA9_43Eg}LouXy$qd?A!6{Q84AOEXvm%8ESkryk}pgCvkRuxLj_&r8SF9^;2o zb0tp~Mk+k&F=8TD&Yz}v?D;%F&|2OHsNS*q=WyqLp&pm2mJ48$2{yWZ( z1RC(?e`z)ZUILkz)K)~94SMN;GObF5;i}Pcb-ip?iTR$g>_Z_xe5MlE^c>e?Jp)0+ zG4fD>M~MxE%~KYM)qP`~wfYG&@RNmV+4ctHqtsfY;x~1Ej{F3o%_Pzzb6ypSJ^fhJ5n~6x#UO_+G;J&9^ftW1$ zi1%$q|0`01iu(&1^1;pYkRF*2#c!ka$-CbzZI{cAcY?=rP)h62fEiwZnY~g!G*z4x zet%tqSs{fXB(zYA>qM!igj;*eD_;0zTk9;c>IBxmg_%8m3iuK{DA0OxUHxZa3t0r3 zp#(?{w;Fmu{xzNm&03ii9Vy;0?yb544i5%DNJB~ovUnc|!R3cJb9g^?TB2b%TSr*7O?7M8>A3 z(C;+c3E&RoO$XYk4{Y(r_x38cN36sC3U*%sfJ;3(mIldg%bk?ndnW)4I5WS*O71G0 z4#FXTpZsKFHO$RZmCw}4>Mz8LTk3j;2J8#P_Vlvf1k@W*vK4fqsZ5&jhP%>5LWFy# zXx{p@(nY@mY6=<{2WyrmAwS$?ZsFnwuAyN&E@1f{df~kz1JDOf4fd|MUW8>|S%-g; zhc=~3C>HQTlY{_aT>eA?xtEIOm>Elpj2?>30OXBk=2ACVuZuwH8;OoflMF#Xy&Z>;JS-;Wh6YOL7M$~jnZwI zB)X#dB8{W`AiZGYV(8WN9p-s)rG@L8gP(xZjy7sc+IoCDl4$sRlK zJ8PG6PM~Q{3^%Dst2za{iWyg;DiIUPm8&qLT*m;7?KL8Wp{i$JXDVcy$~>Z>dBU*( z52RIu*`$9K3IN{a{PqYo*eGbm0~ucD0TpCgmh%E2%Z8QeF^`vX+gfTI!032ERi#=- zx6^S>b`a~TEK4Qn9CkPmX`0Bll)a_729P%}%NsN_-v#2ps3_NGfGjj|seo;mym>T< zxSPs8|8U|PK()vv{^eTe?bhBpp3rjm%34IM_tbcq3qfhLf6XM%!JmK6cKeMM)i?>K znZeetEI|b_UG)Bo71`cK{1VSjrv7U=mI-l$mBPyGOH-v5fri`gf1&{SGh(3q zjBxqWdilE%bwkA)S#-rUtK!I+2eroD-b`%L{#N>3LDZ5Ou_>h~;#3R!_QR^YTKA)>bUChvI#1%_24#K}bjw`) zAaegT;7Iv1$d5X zDH-8nd~re!zYU9Cbo^xt%U)dOiU2LVhk8L8T1K=73G)NU3jb9DV|P_d!&gH?|M~bf za9HL3;5n`I9K0@-xej+K`{=6kA6X+!e)w%C3qWyg9XoRTecz#XU_Z$x%@i)DQ{wB) z1Lz53{YMGCk)0MIl@TYx&yxG=6T+!NdM#9d5duH(efr-mMc#Hg?Xa3TijVasOqV@0 z{OXTA76UkVWI~K#8>!`vQ)iL=;D*EaYo90q-p3Dmc%_*cr0#N-bH?s%*A zRlz<2b`cqAm++z>-&1lv8d}<`H=O;W5Py!Q>DC=;8zx><2R*s@F;7wdR~@lO(QVNe ze@i^L^_iD>)z~-(=hF6tkD&;KgLVk1jGuPA2dDr~WRX9i33NOy&c9QEm4}A*|Hb!y zRw>ffMG<7?^sJHZx}egda~uRC<@)qNwa?CLM^D9w>RXXeL!Jqq1otp>1V|Va)GMcT zXyJNo#68?6bbH$Pc)kC1;|Sp5KFIkIhg29jEE4G*SkqA$_R`|>Pd%a+j*_bP?{8>u z8f`jF(*z8w0xIX5o6Chd!)Pt)&zucdo63!Qg?@fFSs3|W$u0eyZHqrmQ})&Y$4ghq zYg?MiJ^5{98FiPi9(UFp3vLv@3;$GIu5ncIYp?38q4PL%ADw5>s@TAFp-y!RFeHi~ zvA`IcUC>I<2#6r24g3_1;gUgIsDc;4XVN6xb)1a`nC>6mj2y!}ns$HE8GG{@t`=E? zX&^4?6T#STcMN@1Pb?ycFFOQX({i4)P=VzK#oBHApCsg;-YDns8a+3 zq#eMk98hJF8Y*dcl6onhPB@ZLmQRd)~mZ5wtO z(U%#@UMQdH;8V1c$3H;FkFEB0`JZHVQ?#8YFPl6MKtDux>_-pQv- zYK+KqQz}ogyf=_>-Al69+waH!QTCReOyqgvSt2O^T79FImgZ%}`IyIoU(%q8$1x}D zy|&In|4*;T&xf1J!u~u0WaoqhuiE8dGiyh-F;%L2{@h3o{!EZ7D&7Pj&%Gsq`JY%~ zG4$3F&AVJQW%o#%As;WyCR1S3j@7kJ_nRg_P4jX+4sLo4&=W6KviB;aTKd%I*;^KY zA)@)7tu=dy#lAg&oRNK(%lh-f?I5}6;YS^3*i7Xd)Ama;ghQYsnm<;We+ADO%xOCH zZ+ZIf*k?+Ry`2`(AVj_{pv`9QyLNEnUP0yNme1iO%NJZSQXaK$Orq95!dB)@<vrykUK=-VykDr9_$qx)zmp_VxM(e z=(Tpy!!w3P7j2Ff8%bIW5^jbXJ^&q|OeYSO%yEo^X?PbWPg~;m5PF|$wV450_{mq% zf2iR>%XX@(-bL@IYNhUSb7)*nC;uP7aYohGYJ+0y?K=dPfg18RM>WMX`698gAbcot zJa#S1^DviymUyMr@VLvO+6!1D9+MXe1UV+)K4MNY30r!Z|A|}FKGTW3cGq-v9LPn` z8*K3ATyDq1@;!BrdP`6d}a3H8g|>|oax%I<>Z&D zcU~9Jym_KE;mC8~ah)w&{7PuqDH=zXr$d_mSyl-fqx>ZXj`Q)Z-i%ZMAo^+qkT>%% zXQ}5o1dq!N&r&ugeg+Nw;0<)3uolbhYNErm@zC`n=h%@3xO9+)@;J0(I%e(guu<6@oVG# z%I%(@s!#Ce7__4nN&%_VnVl}PPST8Jggk>89%{=+PC{gF;YcJk60Woe`mdH2goUc3o4 zWn~I$*L_A=X+6_8cf+M<3XrLW1L3wyvD31GORvefpx*x`g_M%c(0q3_(I;}E^3!~A z_dK+`-E_j-s?HUkR@vX(>4!EX7@dtP5t(;oS*K54zyG5Av!TrTr2d>a4!hc` zk|`aDoX<=Na&&|sOB4{tC1!i}IQ1eYq522}?@{$QD&@4+L|n#XA1u)xdu!Z&LxPBR z#nxB~YI(jgx1Nj6E#)7x$}2g3ts0o0JtG2t;uoCg>|e3Uh1I;Ady3|9`Tsq#TARV& zYqA$^hM3P;I&^aKp5|kaLyrp*ahW$ zr?@<b$TgXq+f1r;Ev@FzEFrYkqSTdor)88ZlPC&H^ug3F&pky zZha%v$cVlhF9ms;#=`o4C0O-7S``@%BpNt(#oX*;Zo2SM9Lre98^e0*6wT{mi+WOt zRgm}NO`uLSS6@;*^!FeNHVg3)yp4rzSozvV(?=r|2UezqjW$zJ`Ry*>0g*?MTH2jo zX)tamgA!K{1l^P3AAHxrx2Ph?)!dOU7+C%R`>+FymVxd^8ysgt}>c{O|No3NmurOb*pnN|AV;Q{;(ba*;54w3F< zoUQWiLK?sY@kIWNDN6U^ss9^iNV@wjH`$&AmVl3EjnKbQ_sOZ>lQ#Eg1KUJk*X#|9@)x>aeJ`wr@<1 zAQ*rgN-U5DK|qmG1f;uDQf4G1g`pG?0TBu5ZWtK4OGPOOiD6) zAkrY~qVh=j9IEP78-aiGGry99X9GsH7Pw6%op4+%CZMi6H;loH1cDvA*yh;Ad2uAyzZC6gK_DO)cE+%_Mod{NtWCY7=Em z3;@9`VY3rJ>fGyd5pr9H*R{xUjHzQldiFyn)>77yf%`LC^VHJeJpRwab3C-o6?!sJ zb=+N6kt$-$TSb^@CSj1?3eFuJgY)hSC;b5R<~e&3PV^Zi@}cMqG+CN|lJt2~;#jKX z%ru51r9#uhKmVqBBFp^Cxw9U~1i1RHycC#R$j13UGH-M*X&T218M|{b`V12jkV1X~ z0$s`&ks7fP>%Wj+hR>?AT~Nucl?l)i-8tlBdRWV+`QSQ}PRqjC_TIH8h-}fTvk_Xw`iuf^ z>TbVO%Vj96uH2B@62z|2`JokBKde6C>A$co$ku1M(jAbGI-%9jj?l@&1b`4=GeR!p z0(R+`@Am1UX+w$JbG6i@r7W5V^?3 z)KX5bw18)L5v-8Fv_O*4?laAtt!Iql%GF9&5X2FK%;oc2l?bd#E%R*PeYD=l8LQ&* zH%_YPc%cXi$6Frc>bQ-J67+D9|MX^nN3uxMUNR5F`Xqe3++|#!^^RvCI|n1;ry}OG ztdB~onMlZTl2KUGncv1@Z)H#9G>Lx7eVJ#+zN;6o%#u*@s&IkrVd_fQ>epD!6!wk+ zPYB2;hcyiiUa#p6#Xdm}FM#j(@zDvy)IuI(l4 zZ(Qe_*&GwnY_AYp8hYG(IwVD7Z9L2lzotBb$0l>`FQ{)<`(GQ1c-nrdoYP@v!^k$< zCbhy{RIX`*b!iTPnkiW~M-@P;gfbWj{OC1`lW)RdZkDMi z@JiDWzPY|9%O_zhz|VH#-mGrJm##_%7hOVulzPl0b_TCR?W(L`=Hw-{(}$1vku0EQ zo_YwOn1302N`qZHe~!5aWtvnOoo`R-Nh$D#vWdz+8?AFj?lHwsDA^5 zRglpFwpRY~Y_7d^4xhT2NTJbYv9m^Ul_S%QyJzA)@zPt7Fve*rFBfaIbGWPX@2vBk z5P6(CHAf;hJtV($M9+4(QMQ^g`5c|aqDsQNp}g9eZ!y(HqtG zT?#+GlCpKlxh14NLbsMx@{)w&wl1c-RA6brgqUe;>+X_z&R69Xw~|N~PM8acbJq8_ zbL(q=dSyqy7rsrK^<)orj!jU851FWgWHj%GUPtP)vNa7Lmf5;yc4~q=Apau?Qu8%# zFS*YmT<@x>>J2nXB2MHACHmvT=Eu8NN8?nYcmd&32-Co z$ENe23@&FO#1r=fa4!eNm^W)uUz%%O?qtL|g_`%&Q{|p)qXmHw%hI*N+4XDTL$4ni z@%Rk;_wnqza}vnL!j|E2l7m~px=)XhAEYcaims znUA>X3Q~`$w6Vz4wk~2hpXk?AKi^zbZ#?BUYzTXYRxjR6-~qj z>)jC+a-8u#Qf<4(`w!4X-K+#$eT&F{CP;|W8i*L4BXVatS2p)V>uE=-BSfBpfi;Xp zFV2i>5U#kJEl*8~;81ZoFjfsd?rppz0|N^cs^L&%A#GJIPJihqVDtXC;POB=jmV=O zaIoizIu;Y!F9xE2+P&T|+WQNvAC-bEn|Z=dznq5#Ez|%Gui_iVW?BLmFQ~n4U)jJFv*(kaA9SU1L8lhSO0v>OO zb0>%h%@7d7W-Vr_K@h*DEZBgktw`l>$Z{ukr;!ouxF=Vc&8qg*o%EW|nwcrhWry%2 zwaVwb>`_+2;6x5~%ZDduPq@TKTx5y7E9saUB`EZ84tKjhIrg$f|65z`5Y@n_kCw{C zK>)QnFQqGfq^}xb`~2*rdk(5u&?*ke6Fi^Rg?e<;_Wr!vkzzVawY=^=v$Z?{`~^jW z?I0;1-a}Q!P$_ z3ai%^z{8i*?dnRBB8-pU)1JH-5?;1{b>7Wa5}Qos6(SS7L-G*dQoMtwn;gf3PmbuT zSc&eYVE{<|7@Vp5lU~mBlf! zkSuho1SmH=8@+wmAA-9wT_jSo1~gf%T}8t&y)?>4B{fm7Q-+4{0W5)O1!lX&Hpnomy8zE(6DgwOkNkbD}?(N0uVHC~I!8e-qw^N`Xt z&^=auJ?@T-Mg}4V`Ra_W^Z?jXR3zU5m?|&g2R~9HnZK|>4iLz03vbg!bE7`#56{@5 z`~8fx2GxOLp#@1N-=3659h}R5L_%`tqFe}%z|(s|n=aT;b%b#a|Mk;P2u;YO)?X2& zbGW+9#i{7DTWEOXvaVLVY~h(f4n=m@vEs{BTHVY}5O`X^b5B!MHkStXoe!m{lOWZv zeAlN7E#cNmlr}?jTgE2K!V9~dfuqJuoc4;&Q1AEzc4Li85lv+FtwQNFp+W=Jj0l?6 z2oS`^JH6aE(X}`$FJy6sp=Ci$YDG`D<8K zU}(PV?LU{$mmj}5XHn?W%S)I}#z>)9qwUR|22^a7Pa7sz#nGaUh%$qFiCg#W+K572 zc!s*Zn+3L!Os=zm!3nS@FySslcP5nZo{0Hoxt>=7G%UuwAft-Dv3JsYp36dWlF>Q1 z;4&;%LTK?OHe@CysEe8W9sf zl_d;(?m0pbK@Ho8#Tz*)1}S^!ca=2j0xCme>3{GqDklr5*0S5F7iSh6jhffWd`Xx6 zn*V;zTa&Y4N|WZ0UVuzPFqX@N5oFyQ*3nT%-4H{O?v6dX)|MC5M^*0Fq3rq|#;wWe z3SB?RL+q{aOhv4Di$kF|td8orhMq`5TJnm;9~XhR;tGsMzn+^O+Frfx!5wouL|eHa zEy#BEnp|q>8?{d^fsSUh*P#sEUE{758RFKqm*djpQ_1SA`L&iIfu7JGL44&iJF0-t zw}@JMWd`UHf8H0ID}8EEggv{tbE34hds{l@_An}Fj$xcOU2N&ozOq9aLOXQOw`n@x z)Gd6ltK}gj0e?ebT)!3akGM)M0Rn<9MYz~Wv~`WvWP3b+G~=S?kLazjV;i$?Oij&* z!8*FLQa^sqZ98@Gk<8TPLQ^ZP_{fFIbY+>afky{Bj7Dw^I^2M+WjnHI<-@W9Vy$}J z;|iD%P$OF2!IfBUP0iDDL-IM$MBOj8qxQ4WBGJ$K0NxI@ybR|(xzXC5$XfTl!;Qt= z=%=iepuTQ(|KP}fD7C?Cv!R29e3Z)O-H_&*>FB|_%L8Y5iSj{YV26mj56w%^{)=!M z*9ox+kW7ySPZiugX%`lCfq~D|H;cz)J(^*R!H!Czw23gMkOhPP54u%&6TC6z3bVy*3bZm16??{?lr z))uZh@gmA@N05f>kP!86Z(*@h?~YndJT*JT-?&(GbE}*7Gz+cYt?jFpEQ`H4UR0NZ zD6X8qvTfwQL97)Lt{m6%Mbio<#yuU0uE~=R0f}Ya)YCZU398*M9-Ev8>cCU1t5PR~ z+%1Q&Ox6;As$?0?KIAP6PU!rLkM~4&%fxCZYX3O?3eoj5GY093moRZ;Ueo$g$v0wY zq3f5}m@#l$I$G6Q0T-(c}NxW9isy@;B-u{&B=6@BVtlQNV7f#&zD;k{&OtPbP`)D!V$G_K~_` zy^4$x#>y+WAg<1z8vbWjvia_|31Ps^rxIy%>M1egZjsBY4VRdyunHEnTG20leKy+l z+U`8Apqe3=qbByRmX--MtY4~`40z-e=>9S|yKgx*y(Q+$(2L2!?5#dVoJ#$mPG?D6 zhPQ;!Hws#OSiiep^@|;ntK~KCSo{Ff4wHDOZn+fSkOI3yu-x_i zbJ71aRlxB~ev|8!$F?#&4({OynVNZHdQ{jeiPo^w$>)l@e~hg#gi{yaUoHW|1b17( z@-Hj5@5lHfATrW0m6A07WFz5 zhW>?P1arg5pr zDkdRA7wxtx3I-F|%Ff`KA)aCIt6{$HMUezjUJ&q1ukza>*yJ?DnA3ZdAH*sZa_SVR zB;JpH?f|3|@2d_JG5+eR>2+?)Jyxozm32Xnhtu|ENi zuIRQ#Fs(UZv(js{FKbBOq_$9!bErNUbtSD$Sr&*~-$aYp`^Ax7Z)5q4l7IB}8W^=F zyx>44pGDQAe>lO0g&Yy8aimy0*t>*GrtHIMFPR<J4eHJ8P=R8gBEFVg=-%k&1@2mf22@F z2C(yAk_M@`>b)^A;#GMmMz7?mFr9^UvQ)kG<)o0D-tg}7z|(ES zZt!9S{0c>1T#@pLQeNh-xa?Reo+7$#D|Cq?qBq7M+6jOwl@4Ed#dM17 z(xZrV3E}z3ds(cBXc`{69fsDk zM(b*+fQSG(@uXfp(Dzrk`NhG4@P4g%r8w73F1LC;3O<8-6V`tO4wL->I)@rwKS9_0 zmwgDDT)$h8z<2+16^lXgy2f(+-6`A2wA%_5t8?0$n6*h+=Air)PSJ%x->!QNFta zuM63oqX_@iEMCnhD-AMLlv;rv7~Pq-BTk1%Q#_t8E^Rn}=jd`)K6+TIloFS(d&neT zk~$C8f&&i~5j7pOcLB!fxvfzgd|N>zuaI6r!|bx-DbSsf?#S3LwfE8sLA;u|+t`gF z1G?$+lfhNRG-{F2JYekIo+x(%?i>9l>2R*siP5E29B_?qLT6FPv~DQHl5UKjLILU% z);m`imB>cb-uk+ovs9&$ zmE+aJWrphQ-BMmN0CRu^_{s}>?JMp3-tJsmCGZ&s%PuC1MqgPl%)n7x>0`Y80z9)% z&3Tl%O!Ynz9!>g7J5#M2Ev3-y*U5BM*GT?m=NAw?5^;3Etrf2=`C(u$KFO82Pn00hJu2fosY34Lv)5nz>gn8^ScBZnuHK z$!7CgP?($_k8ENug=KB;xeD{gXGx0e#otv;pg;h(`~AUwc2F-8?p7{Y_T-qY`v8I* z7)&e!dpec%NuXWwrj`QN$n-wPSOTB&TB2Kd6k%N3HfKi# z*ayZw#>M;?J8ywxElV-!$ITB7l4qatvY#`J;lpRX-Nh@3Ya==>R|dsK-cebe_jjNx zFX+c+Fbuawp(4xl?k#VQR|Bzo+DmBVC9q>Xz|Rw38G-4!tB0Vq>QQ$xH1_7ju2DbY zwlvzE$(mQ%O>5z5B6`V({fWM3df;x)x0Cg(@)D{6FGbccZSE7zR-M5HyL(ZFsCN}} zd~L-Cj*ZvTKP7{5#b3$^@6h5?w&L)sOXnvC9jrXmJxyavwbzcx`CVH~L_=T!C_jYO zQ*1@Z6#IWZh*Ak3dtL7)Q*iB~?6CmC!S|=(fa5*w3RoZvzMZTs1paQIHvUY=G3{6V zP&Mf4{0wo?v|&L2U}!f(sj-R28oDwY-^m>FLm`Xv3%Vam6`d}bv6*q;0O>iHY6*ik zpHx}O5kbiQSE+{*S0%fLfbOBgB>F{Xf}=2qdx74=B$aolo`a70>6tLrikoM{0p{Ep z9)8Pu_F*|EC$RjJNDo@tq@Pb$18BiC0TL1+C|@e#z{>kBQj=C+mOszqm) z1xZ2QKR@XEY!F*4jMWioxKI#BUph!fwVp}cgTmg_Z+7{rx$&v2S!2a6w@lYmo3HbH zmC~%Zr#4h}l0&Pb9l}DG7IHfMQri};U4JW8BD0+3Xly#t+)${>npNfJ)QwbG|6WFJ zHx!cx91W9Z6f!km2Wqi}Ec@Tf*Z`)xUf|lD~ z@j~mK88`Bhmt)R)?Pf91JZm`$Q(!HejtZASf}b52TE1Fxk_UBklZKpcJNs)rsi|4w zd;3kq@NuEH%PagZT8kyebmJ-|gSwE+PYN*=l9*I}RBzODwds7}47c;>Ok-v$P$147 z41=9u^FMU*p^pg}5c^1EtzOJ?X;I>2XJ~=G%sk(L_z9Vdp9NBLedIF)gpm`n@RDYAQ zFgIsMSvf)vpd!{%xfGGoJ2RwcVQe;ZmBM zU%J|MXAv$lFxf@Y2&eqq|gl+&34J<(irKXYq`Mw1?~8gTi-}BA(C=4iC{rI}j^qiNruKz92m;toD50hAu4e*Du{$7Dct4Y<*aITc639T(rM^x}4^48Ys!A;B4AvmnvX-Aa4wyn5k_i zKWCGGbpccwrB;#&;Jvn>fW7b*pseR}FjJkP18Ws89;M&IR;CW`b0Svjd2Ocs`ff<= zIS?_lCC6|P1H2v1UkGrKO5&so>XHL!e84+rf4e{lZB-RFQFP!1YL3Y~VmoW0biLhb zgxnjuXm0aA^t1VeOh~~$A8cW`bLfP1KyrPecyuRWZ$-(R?l9Pyr; z!9!qi^dkzzu9DwMi$?6j5k}q=R9bW=y7)`fw8zE=`?ml&DA^)?S4t;KV#f;6T#&Nx zj%n+tSw4cr@&Fu67j6lF;xl5H43Ddu4jT}9(|-a>N#>- ztiRqJ;Q@VzC#@rsT5?#qY|2DoXM#4$*zdEEU(tz{`pvrGvn9FgJ;SLIxqW{S@VtP7 z#`i{J){4DEWG*@sY`pywqTHXREJ+Zg3d95vR~_HpTwkbM|H(utzM{MK?y2x2h&v*{ zRkmz#gB9Rav{0lUTFiI`FWbv;S*wew+ywXW2?^&HK__*&c;7e1c9<_1eICyqbIMWJu8 zK~~rJ!^Y#~g5lB=T4zqbkFkAOvitG;HUM5hY;61S6%?Fp#cuKEYt~lS`n8N%P+EjU zd1-y~#ae~Tpb$K7N@oZ5VlI8yGZu#AC9;*DY!$bXV?KR2W%vBsTTpa|MtwzH<9#q~ zXV?aw=kuKzHM-NR|r7%AJ}aX>Ri{a*)BNDmg~(Zl&~%;?v@DNZGe=jn$Ha4Kc?HQ%fHzW+TH8{%8nKN zYYWwaOED#K47>S9^8xg^y_NI1%HTt$kJQk{o~{lkOcY{#!e!gxtFDew{!rz&PpG>Q z#|>%Yf=fNJOC^@~H7PE@A)C8KlSvkr=dC=|YZLS-N&2 zb5isNYjyUY$_4hMJe1@}gh9)rsqcJ_nIZ$1%oYCjgru^rzmy`%U_URf7YJv6=9gYG zgGxjdZ_47H8ITb6lfQDBdcTytauRQU6T}0#4vC&OUFGxVNN=US!)qc_HI8`qj0+b^ z`Nm^O(?--W$tdY{X^GvOt$_AzQc(R?Us%|^#2D}5>DbypY=3J)|Rj6z5m{6GPscgSMS zS*mSZQ`0N%cA7r`w97RrwH_BWV%PX~S3k7bTqu;;$3ZI$qd3xFGy}>HK^Ec2FETr{ z(Thhe(L?JED2KwA)m#4UlfgV)R<0xVofI388a2;NF211YS^d6#mb;6i((x-CsiTXG zGW+s+1O8D~C~HIgHepzedDCgF>jsq5-j?E@O~h;oa-cX6jK6Pjn@fLbaM@kY?#o@??TBZa7^vd4quzLw?(PBA2D*X$^|5&x#gGh^8=X^HJ*6V3V$=oy3@DqC^02z^YI;tmQCik zG_MeLQd0!)8o*TkE(rt*yyzG+RD7H0huHy}*aEX&ff?B~D;!UjZ~|5mwYF*<9(__u zy*_TJRQdv(Zu_bRxL6nPMB!(OSB6f~^3`l0Jt}>1E{)N!JKxWl9^0=`~_3C$; ztGuj_-bCufH&wS!5@%I63tf%T8Ho#ofCjuGFXpc=YRHD;3_WLs(_<^c-#X;Bn+sJg zwdtf#MHRDCG4c_H;3ib^s-^XIBgHP{Sgas}x1+bY5oW0#C$mvPS$wSavKOsqZ_m3} zWQp~+oOUCtF&D3)oR}2)OJJzSu5$IfSU-VmLQ2x|v;1Y#+JxGz`1F?FtMyX}MMIn3 z+W&>W!uj!%KMt88j3SSe_dG_R8H&+&)8MQXh}hr>nH;3APV?Au@9~HPqY7#TT)QF% zzkxzQ|3v9#Yai5eYEU2M+r$xEy%zUvc>N&-nmo9Ke|ZjECUQX0Xf-`ig)3 zf)--PmAJeaEK`%Ho$OcCU55Wb-u!5c_Gtp`jWwPt6Oa3(xEPHyV1m&lv66 zz>bJOsn#;zkuBiJ)yG04d97X51D$e#nbJtlMt~M=3F@EdzVM_cmLdCOt=pf`a9IE) zOAU`KxqXZsKAv+*T5zrFTg@k2nT!1CiBll|DRYNGa9x#TKUxb7g9N!C8?Vkj9|IBt z*<8s$dPN^KNTktUs55;13AAqMIs2SseR6SL+%aw{Dpg`{lU)dWcu6N6!z~YkmDb``ibDQxo ztpE5L(_70C+RF`yw<>iWKHE~~Q81R}L3)pX7%;qg)HKUgo!sv)^Q zgTcbrPRJsB*mNZ*$@qD+l6h%=akm>PJNl!ZJ$Q4Xq~JG^Et?mG_RU zH0kJK+fYzXZSb0%+3h^7~sH`9f z(H9^;#D~pM9atmJ<4U@CEBk&~BLh`%%=DA`?}T^;>?8H{fTWc2k5K^S_gR^tWLR{a zSc(Io9Ha4DM{m3R+GHtAxV03U>|R8IdhM!%39+5~-=Y$8Zf5jMR;u=oBFG+V09BJq zPq7qm2Xi?K$3LG}o0(~k;Tyh48dg?vzfQFh_DH6wzY=iHT^PMB!^Aojd3?5y*0S(e zuHn$=JC@!Gut5kLD9)?t&9p}_bNWJOz?5RLfuS?ztlf!{-yN6whZ?PZ4rB#}doKS0 z!@#(CHv{_|U*9uDbsMm-Vo<;1$HCF7LppW8feIU(v*sE@yoZW{fL-0i{Q=0!4YdFE}n7lf05|&NC zi6i*Kzrx0b=YS7TdCfbUp?ezRO9gmTynb@ntIB1?XY)`JloI%^Py`^uU{}xxnLj@) zDG3obcpm{W$&y?Bb1stWNFrM60`52C!Ukz`6*As;W9iub1Yy>IN?t>~c-!{i?&sc-6{?EvMM7y{hX0GxlYiOT3WgfP53+`Y?oUc;i=b9ck0M zdnf506KCY^zEbW}uu#mA>?fZ>_Q{tU|PT5vcqD;1x#P z_H__;)_}qvofKKi^}K&oXie_jQLW8npi2t?sjE6$Pc%gq7{Czh;VEvcnr~Ov(|ZG} zQHeMLd6q%l9aesiy1P8p?xL22G@+al&6(_D#94jRn+^d1^=%fno@jvDAQ+?!2-0U7 zE3|$to*RW!=@I~~Ydqj>JDA?J&)`QbWpR?tnw@n`wCX~sIf#pUa=YkZTJ@Elfgu5T z%R~Tci0d}w&s>T;iBp8M9;R4(X`GNP=eM~bHE3C_dF61-4X$?a9#kF$L;ONel~^y) zp8>SpR+XQ=h69_KoTGK@AmLTaH`8Ql!H(pzQl-k^&w*xQiI)*%O*}7hG~oplP|$yu zx_C=}(9_BgrY34I1ev>l#Q4D6_4$tDtl^AznvY7A!O6NjRgCQOLxC}}5PMF+3W+t0V7hOR-GRKnZ;jlN^t#rVYiXjPG~DG!DSzVJk7#rMy} ze+9Bnp|ac6meB4Bn&-X$h!B-=yasUJD5yw*-~$JOXM%yfUi9Hl5y&`4qLz#a#5Fge zJ9}M-mJRtpbG0a&R1jqU zT8aLrOkTD#^RWbw#wjWcz!bQ9@-Op(tt8@CN}ITn^#=$Z;uS>wW|1?z-Cg zTbiFa^@Z##gXtCV?7QmJ<>kwh7}&gsaPB`~n;LtTtqd0hYC6wuf<&$8_4orUxrihmrOL(ZXigQbxU zR&SWGGoW8Nq{xBv#oti_h$N+ghSXDMwF80ddvq=rqaitW zf_jA>j-5c{vbj8N%s=c}*cLBh4Qk8ef9GFoB3!`HeQ9n11JiSJGT_VAt#z5c0^M9e8WF8jo$#IKaG-L56s8ws zK`B07msSZ7F(U;_!yXtfR$0Jctu76OowGW_$W5q5!KAV+^H(nmNI9ZW8FfKiqV>?7 z-brE0VJ$u)eS`qV8n_zgzCIxWv-t!o*heYiyfq0Q6JK?aebI+1CY*dJG?wd9x~l3? z0dz9YQ`4S-s#{^yo6jG5Uugp2g^gDMDItL<5zMJ`U5`1NBEf!p&`35R2y0w#u{gu5 zk|EjpBIcqXRIMShGiG#heWFR&dVRLD#i3nOE*ZirSB?wU!z^D$6?>A6qwN?d<<$li zv=hqhsUoy}EkTNKk}StxDZi_#5A&wo{nWC$%urDoXG#94iGE=tm|f{pI>@>}@@ICE z=RiZ2V4))*>gzZ&9N(KU32fR%=ZfDsWw>{#)}@SS3OQ%Z5_X5qC3X#`;^SN_n<*J1 zXT!G0g@u4gI~lTO1>lRFtGa=37^1arTJ+z#987_MD-tYpmiZh5SkWZsHpf)fq&gg7 zwgh)dTV}7Z4B6fD0$%H%Ttp8jvkKf@=Butt$Q6u)^Qe%(H}@r3>Ys}WVV96Sut0CB zCU=8!428dp)=Hm&c4ZvBwzt$0Im3;Tg*{GHYNeUO3+(T#!fzxGK9X(wHiTPx?IN@3 z^7;tD+X?2~?>Wm)rD5QTO9%2ur-(}Yc{A$+nUEjhy(lJsX2=S^>CQJsQgl9Mg>+Vz z?T+CMv5w_#rYL85(Ucl9H*rEa&YVx@EmWL+&<&xdUX9Qhs15^`5BLH>#!f5iBc;L7 zbbCM}#cM*-m!VS~AmnmTnTO|syiOkX`D->*4tnAWC;)U61N7hDxsWfg6WK@Go3_L- zL)-vWkE|~I)|`6eGnx4#(u%g*gp;wMpbSKX3M=TOk`uNrpb$oUr#$X!N#|ekLf9!a zgCF+wuOCxY=bqmoA;eC&dw{KPm=#^~hS3H<{v(kU2P2IEMq&Z;EWDC-7`qe!Xj=YF&%$0TbC% zYht)cCZOPDX|>fEq{_U6>BIy1bI8T)3(xt)W?G_Bzn?9+XXesVvIO8)hWmAsq0Y|J zcqw7XBCO*2S1_h`J0!R`ME#ofwTSl?KXlm&CzY}sg99T0GUV)R-*x^V^Yzp+r_2m< zi4#gPM>S)M*pULxz$NU1>{D4*aDEkeN<+CpX8oyc!-G?Mt$0%`7Bj4_%XPD%u;lg; zT^~n!SxTH^+IOcjBsU#0pej5LWF2j>hy~&@*dGiubzEv^n3r@(7dVW}ZUI4Ci%LPt zy;S=A{YsER5pWSot64Bec`RMu@?UlpFWE)h>NNFXT*J!8f>;UdaMS#ej%sWZRYTUS z>G(aj*1IbGjlc)R;^(GnIo>p?hAfR!_Gnv*8R_$FEeD)>ELE}hW7r}L!u@t2SW4H& zPEfy*Sc?shbr4aYrI~Uk}Iglm6Kwzv5=2DNw}6{ z?e^tyRF&~J>zR-<1G#s?-ob^xSK4X9C0FOeYm(U$eOkiGP2J2Y7UQJZweES?fa~(m zJM@mX6Pxd;TkGwX!wV_6>gAOxDmQVFKV1e7IrA2X90$!%_iy(5zoX#;|M0&#?5S1N zuGQ{{B>qV0FM~$vi#z9_yKm~Zkb~*qYsT?lRrE} z5Jq&6}gMFAZaN$t z3)(Y5L#PAM0XSsSS^8!gT4M+n9)j1v1QD=%-+F&8>+t%gcH^f8<0F4{d3&$OexW<& zH>+Gny9Z`N@BrWeA96_~5Imofd;QJfXM_&e`V0ROai4lRR<6bG{`C+SQC)uM_C1W@ z@HXtALgyb)9`!jwrH-29xpvnPzcx|g~A~TXA2Qux0YgwWAc{n8; zpMe+u-#Y&{U7tbOcrwfGgWqQ9j^p4l?UGfq!y(A*yhvBQvQBaM&h2&c2J+oK5m-15 z&J@g-I}3lY&!attT{5rAt^s#EzttJ|=!-2E1 zEHm7B#>4fuaj~~RxEN`DfWdiw{P{rD|9;5(+ZoA(v2~E}4;UV*3g~~lC;S^uX5=yB^!69>{~3-(f?~sd;vn;XrZa+u)IbYpccl+Ay-dJFBUy zBTB$mw}@Q5noRBY8JJ|F@}aENFtIEQ8vXC@1@S-FDmK_I&VONX0^&JA)7%j>H8q{k zIe3-8)gH_s1FL+&8{nw~I@Z-#SK@;|l20%*Gv9zr3sCcR9zrb&t*{@wQjEBMF);d9 z7Yk}&bbmYY-|a|H)&#W#ro)-W diff --git a/src/Microsoft.OpenApi.Workbench/MainModel.cs b/src/Microsoft.OpenApi.Workbench/MainModel.cs index 7cfbb0084..82e6d11df 100644 --- a/src/Microsoft.OpenApi.Workbench/MainModel.cs +++ b/src/Microsoft.OpenApi.Workbench/MainModel.cs @@ -11,9 +11,9 @@ using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Reader; -using Microsoft.OpenApi.Readers; using Microsoft.OpenApi.Services; using Microsoft.OpenApi.Validations; +using Microsoft.OpenApi.Writers; namespace Microsoft.OpenApi.Workbench { @@ -242,7 +242,7 @@ internal async Task ParseDocumentAsync() : new("file://" + Path.GetDirectoryName(_inputFile) + "/"); } - var readResult = await OpenApiDocument.LoadAsync(stream, Format.GetDisplayName()); + var readResult = await OpenApiDocument.LoadAsync(stream, Format.GetDisplayName().ToLowerInvariant(), settings); var document = readResult.Document; var context = readResult.Diagnostic; @@ -298,13 +298,13 @@ internal async Task ParseDocumentAsync() ///

private async Task WriteContentsAsync(OpenApiDocument document) { - var outputStream = new MemoryStream(); + using var outputStream = new MemoryStream(); await document.SerializeAsync( outputStream, Version, Format, - (Writers.OpenApiWriterSettings)new() + new OpenApiWriterSettings() { InlineLocalReferences = InlineLocal, InlineExternalReferences = InlineExternal From bcd09056e46f7b3f8169ab525693381d5294f034 Mon Sep 17 00:00:00 2001 From: Michael Mutunga Date: Wed, 12 Mar 2025 18:51:42 +0300 Subject: [PATCH 015/984] Add conditional compilation --- .../Reader/V2/OpenApiPathItemDeserializer.cs | 21 +++++++++++++++++-- .../Reader/V3/OpenApiPathItemDeserializer.cs | 4 ++++ .../Reader/V31/OpenApiPathItemDeserializer.cs | 4 ++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi/Reader/V2/OpenApiPathItemDeserializer.cs b/src/Microsoft.OpenApi/Reader/V2/OpenApiPathItemDeserializer.cs index 579e968a2..822f2d4ce 100644 --- a/src/Microsoft.OpenApi/Reader/V2/OpenApiPathItemDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V2/OpenApiPathItemDeserializer.cs @@ -25,7 +25,11 @@ internal static partial class OpenApiV2Deserializer {"delete", (o, n, t) => o.AddOperation(HttpMethod.Delete, LoadOperation(n, t))}, {"options", (o, n, t) => o.AddOperation(HttpMethod.Options, LoadOperation(n, t))}, {"head", (o, n, t) => o.AddOperation(HttpMethod.Head, LoadOperation(n, t))}, +#if NETSTANDARD2_1_OR_GREATER + {"patch", (o, n, t) => o.AddOperation(HttpMethod.Patch, LoadOperation(n, t))}, +#else {"patch", (o, n, t) => o.AddOperation(new HttpMethod("PATCH"), LoadOperation(n, t))}, +#endif { "parameters", LoadPathParameters @@ -63,7 +67,13 @@ private static void LoadPathParameters(OpenApiPathItem pathItem, ParseNode node, var requestBody = CreateRequestBody(node.Context, bodyParameter); foreach (var opPair in pathItem.Operations.Where(x => x.Value.RequestBody is null)) { - if (opPair.Key == HttpMethod.Post || opPair.Key == HttpMethod.Put || opPair.Key == new HttpMethod("PATCH")) + if (opPair.Key == HttpMethod.Post || opPair.Key == HttpMethod.Put +#if NETSTANDARD2_1_OR_GREATER + || opPair.Key == HttpMethod.Patch +#else + || opPair.Key == new HttpMethod("PATCH") +#endif + ) { opPair.Value.RequestBody = requestBody; } @@ -77,13 +87,20 @@ private static void LoadPathParameters(OpenApiPathItem pathItem, ParseNode node, var requestBody = CreateFormBody(node.Context, formParameters); foreach (var opPair in pathItem.Operations.Where(x => x.Value.RequestBody is null)) { - if (opPair.Key == HttpMethod.Post || opPair.Key == HttpMethod.Put || opPair.Key == new HttpMethod("PATCH")) + if (opPair.Key == HttpMethod.Post || opPair.Key == HttpMethod.Put +#if NETSTANDARD2_1_OR_GREATER + || opPair.Key == HttpMethod.Patch +#else + || opPair.Key == new HttpMethod("PATCH") +#endif + ) { opPair.Value.RequestBody = requestBody; } } } } + } } } diff --git a/src/Microsoft.OpenApi/Reader/V3/OpenApiPathItemDeserializer.cs b/src/Microsoft.OpenApi/Reader/V3/OpenApiPathItemDeserializer.cs index b81f2d45d..c855fa55c 100644 --- a/src/Microsoft.OpenApi/Reader/V3/OpenApiPathItemDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V3/OpenApiPathItemDeserializer.cs @@ -33,7 +33,11 @@ internal static partial class OpenApiV3Deserializer {"delete", (o, n, t) => o.AddOperation(HttpMethod.Delete, LoadOperation(n, t))}, {"options", (o, n, t) => o.AddOperation(HttpMethod.Options, LoadOperation(n, t))}, {"head", (o, n, t) => o.AddOperation(HttpMethod.Head, LoadOperation(n, t))}, +#if NETSTANDARD2_1_OR_GREATER + {"patch", (o, n, t) => o.AddOperation(HttpMethod.Patch, LoadOperation(n, t))}, +#else {"patch", (o, n, t) => o.AddOperation(new HttpMethod("PATCH"), LoadOperation(n, t))}, +#endif {"trace", (o, n, t) => o.AddOperation(HttpMethod.Trace, LoadOperation(n, t))}, {"servers", (o, n, t) => o.Servers = n.CreateList(LoadServer, t)}, {"parameters", (o, n, t) => o.Parameters = n.CreateList(LoadParameter, t)} diff --git a/src/Microsoft.OpenApi/Reader/V31/OpenApiPathItemDeserializer.cs b/src/Microsoft.OpenApi/Reader/V31/OpenApiPathItemDeserializer.cs index 9f9b644d7..21da96d3d 100644 --- a/src/Microsoft.OpenApi/Reader/V31/OpenApiPathItemDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V31/OpenApiPathItemDeserializer.cs @@ -35,7 +35,11 @@ internal static partial class OpenApiV31Deserializer {"delete", (o, n, t) => o.AddOperation(HttpMethod.Delete, LoadOperation(n, t))}, {"options", (o, n, t) => o.AddOperation(HttpMethod.Options, LoadOperation(n, t))}, {"head", (o, n, t) => o.AddOperation(HttpMethod.Head, LoadOperation(n, t))}, +#if NETSTANDARD2_1_OR_GREATER + {"patch", (o, n, t) => o.AddOperation(HttpMethod.Patch, LoadOperation(n, t))}, +#else {"patch", (o, n, t) => o.AddOperation(new HttpMethod("PATCH"), LoadOperation(n, t))}, +#endif {"trace", (o, n, t) => o.AddOperation(HttpMethod.Trace, LoadOperation(n, t))}, {"servers", (o, n, t) => o.Servers = n.CreateList(LoadServer, t)}, {"parameters", (o, n, t) => o.Parameters = n.CreateList(LoadParameter, t)} From 8fdb48a742ad377698952371c3b186da0defbe00 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 12 Mar 2025 21:25:44 +0000 Subject: [PATCH 016/984] chore(deps): bump Verify.Xunit from 28.14.0 to 28.14.1 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 28.14.0 to 28.14.1. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/28.14.0...28.14.1) --- updated-dependencies: - dependency-name: Verify.Xunit dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 922b16e22..0ff458735 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -14,7 +14,7 @@ - + From c6e6be27f01136a3dae023c1740c20da22763f62 Mon Sep 17 00:00:00 2001 From: Michael Mutunga Date: Thu, 13 Mar 2025 10:22:58 +0300 Subject: [PATCH 017/984] Remove the redundant cast --- src/Microsoft.OpenApi/Services/OpenApiFilterService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs index 1e109a41d..b17195c3b 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs @@ -108,7 +108,7 @@ public static OpenApiDocument CreateFilteredDocument(OpenApiDocument source, Fun if (result.CurrentKeys.Operation != null) { - pathItem.Operations.Add((HttpMethod)result.CurrentKeys.Operation, result.Operation); + pathItem.Operations.Add(result.CurrentKeys.Operation, result.Operation); if (result.Parameters?.Any() ?? false) { From 5a3826cd02297560356d65f9056d924e6d4d4def Mon Sep 17 00:00:00 2001 From: Musale Martin Date: Thu, 13 Mar 2025 12:11:21 +0300 Subject: [PATCH 018/984] chore: update the readme for hidi examples and commands --- src/Microsoft.OpenApi.Hidi/readme.md | 112 ++++++++++++++++----------- 1 file changed, 67 insertions(+), 45 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/readme.md b/src/Microsoft.OpenApi.Hidi/readme.md index 55986d14b..7a7667e02 100644 --- a/src/Microsoft.OpenApi.Hidi/readme.md +++ b/src/Microsoft.OpenApi.Hidi/readme.md @@ -17,21 +17,22 @@ Install [Microsoft.OpenApi.Hidi](https://www.nuget.org/packages/Microsoft.OpenAp ### .NET CLI(Global) - 1. dotnet tool install --global Microsoft.OpenApi.Hidi --prerelease - +```bash +dotnet tool install --global Microsoft.OpenApi.Hidi --prerelease +``` ### .NET CLI(local) - - 1. dotnet new tool-manifest #if you are setting up the OpenAPI.NET repo - 2. dotnet tool install --local Microsoft.OpenApi.Hidi --prerelease +```bash +dotnet new tool-manifest #if you are setting up the OpenAPI.NET repo +dotnet tool install --local Microsoft.OpenApi.Hidi --prerelease +``` ## How to use Hidi -Once you've installed the package locally, you can invoke the Hidi by running: hidi [command]. -You can access the list of command options we have by running hidi -h +Once you've installed the package locally, you can invoke the Hidi by running: `hidi [command]`. You can access the list of command options we have by running `hidi -h` The tool avails the following commands: • Validate @@ -57,9 +58,13 @@ It accepts the following command: • --loglevel(-ll) - The log level to use when logging messages to the main output -**Example:** `hidi.exe validate --openapi C:\OpenApidocs\Mail.yml --loglevel trace` +#### Example: -Run validate -h to see the options available. +```bash +hidi validate --openapi C:\OpenApidocs\Mail.yml --loglevel trace` +``` + +> Run `hidi validate -h` to see the options available. ### Transform @@ -67,53 +72,70 @@ Used to convert file formats from JSON to YAML and vice versa and performs slici This command accepts the following parameters: - • --openapi(-d) - OpenAPI description file path in the local filesystem or a valid URL hosted on a HTTPS server - • --csdl(--cs) - CSDL file path in the local filesystem or a valid URL hosted on a HTTPS server - • --csdlfilter(--csf) - a filter parameter that a user can use to select a subset of a large CSDL file. They do so by providing a comma delimited list of EntitySet and Singleton names that appear in the EntityContainer. - • --output(-o) - Output directory path for the transformed document. - • --output-folder(--of) - The output directory path for the generated files. - • --clean-ouput(--co) - an optional param that allows a user to overwrite an existing file. - • --version(-v) - OpenAPI specification version. - • --metadata-version(--mv) - the metadata version to use. - • --format(-f) - File format - • --terse-output(--to) - Produce terse json output - • --settings-path(--sp) - The configuration file with CSDL conversion settings. - • --loglevel(--ll) - The log level to use when logging messages to the main output - • --inline-local - Inline local $ref instances - • --inline-external(--ex) - Inline external $refs - • --filterByOperationIds(--op) - Slice document based on OperationId(s) provided. Accepts a comma delimited list of operation ids. - • --filterByTags(-t) - Slice document based on tag(s) provided. Accepts a comma delimited list of tags. - • --filterByCollection(-c) - Slices the OpenAPI document based on the Postman Collection file generated by Resource Explorer - • --manifest (-m) - Slices the OpenAPI document based on the requests defined in the API Manifest file referenced by the provided URI. For API manifests with multiple API Dependenties, use a fragment identifier to select the desired one. e.g ./apimanifest.json#example + + • --openapi, (-d) - OpenAPI description file path in the local filesystem or a valid URL hosted on a HTTPS server + • --csdl (--cs) - CSDL file path in the local filesystem or a valid URL hosted on a HTTPS server + • --csdl-filter (--csf) - a filter parameter that a user can use to select a subset of a large CSDL file. They do so by providing a comma delimited list of EntitySet and Singleton names that appear in the EntityContainer. + • --output (-o) - Output directory path for the transformed document. + • --clean-output (--co) - an optional param that allows a user to overwrite an existing file. + • --version (-v) - OpenAPI specification version. + • --metadata-version (--mv) - the metadata version to use. + • --format (-f) - File format + • --terse-output (--to) - Produce terse json output + • --settings-path (--sp) - The configuration file with CSDL conversion settings. + • --log-level (--ll) - The log level to use when logging messages to the main output + • --inline-local (--il) - Inline local $ref instances + • --inline-external (--ie) - Inline external $refs instances + • --filter-by-operationids(--op) - Slice document based on OperationId(s) provided. Accepts a comma delimited list of operation ids. + • --filter-by-tags (--t) - Slice document based on tag(s) provided. Accepts a comma delimited list of tags. + • --filter-by-collection (-c) - Slices the OpenAPI document based on the Postman Collection file generated by Resource Explorer - **Examples:** + #### Examples: - 1. Filtering by OperationIds - hidi transform -d files\People.yml -f yaml -o files\People.yml -v OpenApi3_0 --op users_UpdateInsights --co - - 2. Filtering by Postman collection - hidi transform --openapi files\People.yml --format yaml --output files\People2.yml --version OpenApi3_0 --filterByCollection Graph-Collection-0017059134807617005.postman_collection.json - - 3. CSDL--->OpenAPI conversion and filtering - hidi transform --csdl Files/Todo.xml --output Files/Todo-subset.yml --format yaml --version OpenApi3_0 --filterByOperationIds Todos.Todo.UpdateTodo - - 4. CSDL Filtering by EntitySets and Singletons - hidi transform --cs dataverse.csdl --csdlFilter "appointments,opportunities" -o appointmentsAndOpportunities.yaml --ll trace - -Run transform -h to see all the available usage options. +1. Filtering by OperationIds + +```bash +hidi transform -d files\People.yml -f yaml -o files\People.yml -v OpenApi3_0 --op users_UpdateInsights --co +``` + +2. Filtering by Postman collection + +```bash +hidi transform --openapi files\People.yml --format yaml --output files\People2.yml --version OpenApi3_0 --filter-by-collection Graph-Collection-0017059134807617005.postman_collection.json +``` + +3. CSDL--->OpenAPI conversion and filtering + +```bash +hidi transform --csdl Files/Todo.xml --output Files/Todo-subset.yml --format yaml --version OpenApi3_0 --filter-by-operationids Todos.Todo.UpdateTodo +``` + +4. CSDL Filtering by EntitySets and Singletons + +```bash +hidi transform --cs dataverse.csdl --csdl-filter "appointments,opportunities" -o appointmentsAndOpportunities.yaml --ll trace +``` + +> Run `hidi transform -h` to see all the available usage options. ### Show This command accepts an OpenAPI document as an input parameter and generates a Markdown file that contains a diagram of the API using Mermaid syntax. -**Examples:** +#### Examples: - 1. hidi show -d files\People.yml -o People.md -ll trace +```bash +hidi show -d files\People.yml -o People.md -ll trace +``` ### Plugin This command generates an OpenAI style Plugin manifest and minimal OpenAPI file based on the provided API Manifest -**Examples:** +#### Examples: + +```bash +hidi plugin -m exampleApiManifest.yml -o mypluginfolder +``` - 1. hidi plugin -m exampleApiManifest.yml -o mypluginfolder +> Run `hidi plugin -h` to see all the available usage options. \ No newline at end of file From 876f292807454dc4e14587a1c601a1b8b4c636d6 Mon Sep 17 00:00:00 2001 From: martincostello Date: Thu, 13 Mar 2025 13:09:21 +0000 Subject: [PATCH 019/984] Add OpenApiDocument.SerializeAs() Resolves #2231. --- .../Models/OpenApiDocument.cs | 29 + ...WorksAsync_version=OpenApi2_0.verified.txt | 417 +++++++++++++++ ...WorksAsync_version=OpenApi3_0.verified.txt | 495 ++++++++++++++++++ ...WorksAsync_version=OpenApi3_1.verified.txt | 495 ++++++++++++++++++ .../Models/OpenApiDocumentTests.cs | 44 ++ .../PublicApi/PublicApi.approved.txt | 1 + 6 files changed, 1481 insertions(+) create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsVersionJsonWorksAsync_version=OpenApi2_0.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsVersionJsonWorksAsync_version=OpenApi3_0.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsVersionJsonWorksAsync_version=OpenApi3_1.verified.txt diff --git a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs index 164b3330b..3354a6717 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs @@ -147,6 +147,35 @@ public OpenApiDocument(OpenApiDocument? document) BaseUri = document?.BaseUri != null ? document.BaseUri : new(OpenApiConstants.BaseRegistryUri + Guid.NewGuid()); } + /// + /// Serialize to an Open API document using the specified version. + /// + /// The Open API specification version to serialize the document as. + /// The to serialize the document to. + /// + /// is not a supported Open API specification version. + /// + public void SerializeAs(OpenApiSpecVersion version, IOpenApiWriter writer) + { + switch (version) + { + case OpenApiSpecVersion.OpenApi2_0: + SerializeAsV2(writer); + break; + + case OpenApiSpecVersion.OpenApi3_0: + SerializeAsV3(writer); + break; + + case OpenApiSpecVersion.OpenApi3_1: + SerializeAsV31(writer); + break; + + default: + throw new ArgumentOutOfRangeException(nameof(version), version, string.Format(Properties.SRResource.OpenApiSpecVersionNotSupported, version)); + } + } + /// /// Serialize to Open API v3.1 document. /// diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsVersionJsonWorksAsync_version=OpenApi2_0.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsVersionJsonWorksAsync_version=OpenApi2_0.verified.txt new file mode 100644 index 000000000..09804c666 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsVersionJsonWorksAsync_version=OpenApi2_0.verified.txt @@ -0,0 +1,417 @@ +{ + "swagger": "2.0", + "info": { + "title": "Swagger Petstore (Simple)", + "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification", + "termsOfService": "http://helloreverb.com/terms/", + "contact": { + "name": "Swagger API team", + "url": "http://swagger.io", + "email": "foo@example.com" + }, + "license": { + "name": "MIT", + "url": "http://opensource.org/licenses/MIT" + }, + "version": "1.0.0" + }, + "host": "petstore.swagger.io", + "basePath": "/api", + "schemes": [ + "http" + ], + "paths": { + "/pets": { + "get": { + "description": "Returns all pets from the system that the user has access to", + "operationId": "findPets", + "produces": [ + "application/json", + "application/xml", + "text/html" + ], + "parameters": [ + { + "in": "query", + "name": "tags", + "description": "tags to filter by", + "type": "array", + "items": { + "type": "string" + }, + "collectionFormat": "multi" + }, + { + "in": "query", + "name": "limit", + "description": "maximum number of results to return", + "type": "integer", + "format": "int32" + } + ], + "responses": { + "200": { + "description": "pet response", + "schema": { + "type": "array", + "items": { + "type": "object", + "required": [ + "id", + "name" + ], + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + } + }, + "4XX": { + "description": "unexpected client error", + "schema": { + "type": "object", + "required": [ + "code", + "message" + ], + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "schema": { + "type": "object", + "required": [ + "code", + "message" + ], + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "post": { + "description": "Creates a new pet in the store. Duplicates are allowed", + "operationId": "addPet", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json", + "text/html" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "description": "Pet to add to the store", + "required": true, + "schema": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + } + ], + "responses": { + "200": { + "description": "pet response", + "schema": { + "type": "object", + "required": [ + "id", + "name" + ], + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + }, + "4XX": { + "description": "unexpected client error", + "schema": { + "type": "object", + "required": [ + "code", + "message" + ], + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "schema": { + "type": "object", + "required": [ + "code", + "message" + ], + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + } + }, + "/pets/{id}": { + "get": { + "description": "Returns a user based on a single ID, if the user does not have access to the pet", + "operationId": "findPetById", + "produces": [ + "application/json", + "application/xml", + "text/html" + ], + "parameters": [ + { + "in": "path", + "name": "id", + "description": "ID of pet to fetch", + "required": true, + "type": "integer", + "format": "int64" + } + ], + "responses": { + "200": { + "description": "pet response", + "schema": { + "type": "object", + "required": [ + "id", + "name" + ], + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + }, + "4XX": { + "description": "unexpected client error", + "schema": { + "type": "object", + "required": [ + "code", + "message" + ], + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "schema": { + "type": "object", + "required": [ + "code", + "message" + ], + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "delete": { + "description": "deletes a single pet based on the ID supplied", + "operationId": "deletePet", + "produces": [ + "text/html" + ], + "parameters": [ + { + "in": "path", + "name": "id", + "description": "ID of pet to delete", + "required": true, + "type": "integer", + "format": "int64" + } + ], + "responses": { + "204": { + "description": "pet deleted" + }, + "4XX": { + "description": "unexpected client error", + "schema": { + "type": "object", + "required": [ + "code", + "message" + ], + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "schema": { + "type": "object", + "required": [ + "code", + "message" + ], + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + } + } + }, + "definitions": { + "pet": { + "type": "object", + "required": [ + "id", + "name" + ], + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + }, + "newPet": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + }, + "errorModel": { + "type": "object", + "required": [ + "code", + "message" + ], + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsVersionJsonWorksAsync_version=OpenApi3_0.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsVersionJsonWorksAsync_version=OpenApi3_0.verified.txt new file mode 100644 index 000000000..5d9d7f3da --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsVersionJsonWorksAsync_version=OpenApi3_0.verified.txt @@ -0,0 +1,495 @@ +{ + "openapi": "3.0.4", + "info": { + "title": "Swagger Petstore (Simple)", + "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification", + "termsOfService": "http://helloreverb.com/terms/", + "contact": { + "name": "Swagger API team", + "url": "http://swagger.io", + "email": "foo@example.com" + }, + "license": { + "name": "MIT", + "url": "http://opensource.org/licenses/MIT" + }, + "version": "1.0.0" + }, + "servers": [ + { + "url": "http://petstore.swagger.io/api" + } + ], + "paths": { + "/pets": { + "get": { + "description": "Returns all pets from the system that the user has access to", + "operationId": "findPets", + "parameters": [ + { + "name": "tags", + "in": "query", + "description": "tags to filter by", + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + }, + { + "name": "limit", + "in": "query", + "description": "maximum number of results to return", + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "200": { + "description": "pet response", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + } + }, + "application/xml": { + "schema": { + "type": "array", + "items": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + } + } + } + }, + "4XX": { + "description": "unexpected client error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + } + } + }, + "post": { + "description": "Creates a new pet in the store. Duplicates are allowed", + "operationId": "addPet", + "requestBody": { + "description": "Pet to add to the store", + "content": { + "application/json": { + "schema": { + "required": [ + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "pet response", + "content": { + "application/json": { + "schema": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + } + } + }, + "4XX": { + "description": "unexpected client error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + } + } + } + }, + "/pets/{id}": { + "get": { + "description": "Returns a user based on a single ID, if the user does not have access to the pet", + "operationId": "findPetById", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "ID of pet to fetch", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "200": { + "description": "pet response", + "content": { + "application/json": { + "schema": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + }, + "application/xml": { + "schema": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + } + } + }, + "4XX": { + "description": "unexpected client error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + } + } + }, + "delete": { + "description": "deletes a single pet based on the ID supplied", + "operationId": "deletePet", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "ID of pet to delete", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "204": { + "description": "pet deleted" + }, + "4XX": { + "description": "unexpected client error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "pet": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + }, + "newPet": { + "required": [ + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + }, + "errorModel": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsVersionJsonWorksAsync_version=OpenApi3_1.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsVersionJsonWorksAsync_version=OpenApi3_1.verified.txt new file mode 100644 index 000000000..3c9768fe9 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsVersionJsonWorksAsync_version=OpenApi3_1.verified.txt @@ -0,0 +1,495 @@ +{ + "openapi": "3.1.1", + "info": { + "title": "Swagger Petstore (Simple)", + "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification", + "termsOfService": "http://helloreverb.com/terms/", + "contact": { + "name": "Swagger API team", + "url": "http://swagger.io", + "email": "foo@example.com" + }, + "license": { + "name": "MIT", + "url": "http://opensource.org/licenses/MIT" + }, + "version": "1.0.0" + }, + "servers": [ + { + "url": "http://petstore.swagger.io/api" + } + ], + "paths": { + "/pets": { + "get": { + "description": "Returns all pets from the system that the user has access to", + "operationId": "findPets", + "parameters": [ + { + "name": "tags", + "in": "query", + "description": "tags to filter by", + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + }, + { + "name": "limit", + "in": "query", + "description": "maximum number of results to return", + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "200": { + "description": "pet response", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + } + }, + "application/xml": { + "schema": { + "type": "array", + "items": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + } + } + } + }, + "4XX": { + "description": "unexpected client error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + } + } + }, + "post": { + "description": "Creates a new pet in the store. Duplicates are allowed", + "operationId": "addPet", + "requestBody": { + "description": "Pet to add to the store", + "content": { + "application/json": { + "schema": { + "required": [ + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "pet response", + "content": { + "application/json": { + "schema": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + } + } + }, + "4XX": { + "description": "unexpected client error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + } + } + } + }, + "/pets/{id}": { + "get": { + "description": "Returns a user based on a single ID, if the user does not have access to the pet", + "operationId": "findPetById", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "ID of pet to fetch", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "200": { + "description": "pet response", + "content": { + "application/json": { + "schema": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + }, + "application/xml": { + "schema": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + } + } + }, + "4XX": { + "description": "unexpected client error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + } + } + }, + "delete": { + "description": "deletes a single pet based on the ID supplied", + "operationId": "deletePet", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "ID of pet to delete", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "204": { + "description": "pet deleted" + }, + "4XX": { + "description": "unexpected client error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "pet": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + }, + "newPet": { + "required": [ + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + }, + "errorModel": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs index b286839ac..683b3d06c 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs @@ -2134,5 +2134,49 @@ public void DeduplicatesTags() Assert.Contains(document.Tags, t => t.Name == "tag1"); Assert.Contains(document.Tags, t => t.Name == "tag2"); } + + public static TheoryData OpenApiSpecVersions() + { + var values = new TheoryData(); + + foreach (var value in Enum.GetValues()) + { + values.Add(value); + } + + return values; + } + + [Theory] + [MemberData(nameof(OpenApiSpecVersions))] + public async Task SerializeAdvancedDocumentAsVersionJsonWorksAsync(OpenApiSpecVersion version) + { + // Arrange + using var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = false }); + + // Act + AdvancedDocument.SerializeAs(version, writer); + await writer.FlushAsync(); + + // Assert + await Verifier.Verify(outputStringWriter).UseParameters(version); + } + + [Fact] + public void SerializeAsThrowsIfVersionIsNotSupported() + { + // Arrange + using var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = false }); + var version = (OpenApiSpecVersion)int.MaxValue; + + // Act + var actual = Assert.Throws(() => AdvancedDocument.SerializeAs(version, writer)); + + // Assert + Assert.Equal("version", actual.ParamName); + Assert.Equal(version, actual.ActualValue); + } } } diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index 74afafa5a..0da556db0 100644 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -727,6 +727,7 @@ namespace Microsoft.OpenApi.Models public bool AddComponent(string id, T componentToRegister) { } public System.Threading.Tasks.Task GetHashCodeAsync(System.Threading.CancellationToken cancellationToken = default) { } public void RegisterComponents() { } + public void SerializeAs(Microsoft.OpenApi.OpenApiSpecVersion version, Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } From b9f7d95fcd9dc12d45c6dd9a5adf09a32e63d35b Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Thu, 13 Mar 2025 14:43:30 -0400 Subject: [PATCH 020/984] ci: fixes an issue where the unit tests would depend on a service experiencing an outage --- .../V3Tests/OpenApiDocumentTests.cs | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs index d46d33de9..77eceb66d 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs @@ -6,8 +6,12 @@ using System.Globalization; using System.IO; using System.Linq; +using System.Net; +using System.Net.Http; +using System.Net.Http.Headers; using System.Text; using System.Text.Json.Nodes; +using System.Threading; using System.Threading.Tasks; using FluentAssertions; using Microsoft.OpenApi.Extensions; @@ -20,6 +24,8 @@ using Microsoft.OpenApi.Validations; using Microsoft.OpenApi.Validations.Rules; using Microsoft.OpenApi.Writers; +using Moq; +using Moq.Protected; using Xunit; namespace Microsoft.OpenApi.Readers.Tests.V3Tests @@ -28,8 +34,6 @@ namespace Microsoft.OpenApi.Readers.Tests.V3Tests public class OpenApiDocumentTests { private const string SampleFolderPath = "V3Tests/Samples/OpenApiDocument/"; - private const string codacyApi = "https://api.codacy.com/api/api-docs/swagger.yaml"; - private static async Task CloneAsync(T element) where T : class, IOpenApiSerializable { using var stream = new MemoryStream(); @@ -1493,8 +1497,24 @@ public async Task ParseDocumentWithExampleReferencesPasses() [Fact] public async Task ParseDocumentWithNonStandardMIMETypePasses() { + var path = Path.Combine(SampleFolderPath, "basicDocumentWithMultipleServers.yaml"); + using var stream = Resources.GetStream(path); + using var streamReader = new StreamReader(stream); + var contentAsString = await streamReader.ReadToEndAsync(); + var mockMessageHandler = new Mock(); + mockMessageHandler.Protected() + .Setup>("SendAsync", ItExpr.IsAny(), ItExpr.IsAny()) + .ReturnsAsync(new HttpResponseMessage { + StatusCode = HttpStatusCode.OK, + Content = new StringContent(contentAsString, new MediaTypeHeaderValue("text/x-yaml")) + }); + var settings = new OpenApiReaderSettings + { + HttpClient = new HttpClient(mockMessageHandler.Object) + }; + settings.AddYamlReader(); // Act & Assert: Ensure NotSupportedException is not thrown for non-standard MIME type: text/x-yaml - var result = await OpenApiDocument.LoadAsync(codacyApi, SettingsFixture.ReaderSettings); + var result = await OpenApiDocument.LoadAsync("https://localhost/doesntmatter/foo.bar", settings); Assert.NotNull(result.Document); } } From 8f892c39ee6e0973018b20c870e0dfa43f741ad1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 13 Mar 2025 21:19:46 +0000 Subject: [PATCH 021/984] chore(deps): bump Verify.Xunit from 28.14.1 to 28.15.0 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 28.14.1 to 28.15.0. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/commits) --- updated-dependencies: - dependency-name: Verify.Xunit dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 0ff458735..36e360d6c 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -14,7 +14,7 @@ - + From 96574ecc46dca647a708b6673c7e5309824eda2f Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Fri, 14 Mar 2025 16:36:14 +0300 Subject: [PATCH 022/984] feat: enable null reference type support (#2146) * feat: enable NRT * fix: dereference of a possible null reference * chore: code cleanup * chore: convert to conditional expression * Update src/Microsoft.OpenApi/Models/OpenApiOperation.cs Co-authored-by: Vincent Biret * Update src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs Co-authored-by: Vincent Biret * chore: PR feedback * fix: resolve merge conflict errors * chore: remove deprecated code and tests; make param required * chore: code refactor and cleanup * chore: update public API * chore: address PR comments * fix: remove nullable Json node params * chore: use conditional compilation to make reference a required field * refactor: apply nullable to new changes * chore: bad merge Signed-off-by: Vincent Biret * chore: simplifies filtering condition * Update src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs Co-authored-by: Vincent Biret * chore: address more PR feedback * chore: add check for both null and empty strings * chore: revert to include check for empty strings * chore: cleanup * chore: clean up public API * Update src/Microsoft.OpenApi/Reader/Services/OpenApiRemoteReferenceCollector.cs Co-authored-by: Vincent Biret * fix: resolve PR feedback * chore: add defensive programming * chore: resolve merge conflicts * chore: more refactoring * Update src/Microsoft.OpenApi/Reader/V2/OpenApiOperationDeserializer.cs Co-authored-by: Vincent Biret * Update src/Microsoft.OpenApi/Reader/V2/OpenApiPathItemDeserializer.cs Co-authored-by: Vincent Biret * Update src/Microsoft.OpenApi/Reader/V31/OpenApiServerVariableDeserializer.cs Co-authored-by: Vincent Biret * Update src/Microsoft.OpenApi/Reader/V31/OpenApiSecurityRequirementDeserializer.cs Co-authored-by: Vincent Biret * Update src/Microsoft.OpenApi/Reader/V2/OpenApiSecurityRequirementDeserializer.cs Co-authored-by: Vincent Biret * Update src/Microsoft.OpenApi/Reader/V3/OpenApiServerVariableDeserializer.cs Co-authored-by: Vincent Biret * Update src/Microsoft.OpenApi/Reader/V3/OpenApiSecurityRequirementDeserializer.cs Co-authored-by: Vincent Biret * chore: another round of refactoring * chore: clean up nullability of params * fix: compiler errors * fix: remove redundant cast and update public API * chore: fix merge conflict issues * chore: apply copilot suggestion * Update src/Microsoft.OpenApi/Services/OpenApiWalker.cs --------- Signed-off-by: Vincent Biret Co-authored-by: Vincent Biret --- .../Formatters/PowerShellFormatter.cs | 13 +- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 146 ++-- .../Microsoft.OpenApi.Readers.csproj | 1 + .../OpenApiYamlReader.cs | 6 +- .../Exceptions/OpenApiException.cs | 4 +- .../Exceptions/OpenApiReaderException.cs | 13 +- .../Exceptions/OpenApiWriterException.cs | 2 +- .../Expressions/BodyExpression.cs | 4 +- .../Expressions/HeaderExpression.cs | 2 +- .../Expressions/PathExpression.cs | 2 +- .../Expressions/QueryExpression.cs | 2 +- .../Expressions/RuntimeExpression.cs | 4 +- .../Expressions/SourceExpression.cs | 4 +- .../Extensions/EnumExtensions.cs | 4 +- .../Extensions/OpenApiElementExtensions.cs | 8 +- .../Extensions/OpenApiExtensibleExtensions.cs | 5 +- .../OpenApiReferencableExtensions.cs | 23 +- .../OpenApiSerializableExtensions.cs | 4 +- .../Extensions/OpenApiServerExtensions.cs | 50 +- .../Extensions/StringExtensions.cs | 14 +- .../Helpers/JsonNodeCloneHelper.cs | 4 +- .../Interfaces/IMetadataContainer.cs | 2 +- .../Interfaces/IOpenApiExtensible.cs | 2 +- .../Interfaces/IOpenApiReadOnlyExtensible.cs | 4 +- .../Interfaces/IOpenApiReader.cs | 2 +- .../Interfaces/IOpenApiReferenceHolder.cs | 6 +- .../Interfaces/IOpenApiVersionService.cs | 16 +- .../Interfaces/IShallowCopyable.cs | 2 +- src/Microsoft.OpenApi/JsonPointer.cs | 2 +- .../Microsoft.OpenApi.csproj | 1 + .../OpenApiDeprecationExtension.cs | 2 +- .../OpenApiEnumValuesDescriptionExtension.cs | 2 +- .../OpenApiPagingExtension.cs | 2 +- .../OpenApiPrimaryErrorMessageExtension.cs | 2 +- .../OpenApiReservedParameterExtension.cs | 2 +- .../Models/Interfaces/IOpenApiCallback.cs | 4 +- .../Interfaces/IOpenApiDescribedElement.cs | 6 +- .../Models/Interfaces/IOpenApiExample.cs | 6 +- .../Models/Interfaces/IOpenApiHeader.cs | 10 +- .../Models/Interfaces/IOpenApiLink.cs | 12 +- .../Models/Interfaces/IOpenApiParameter.cs | 12 +- .../Models/Interfaces/IOpenApiPathItem.cs | 6 +- .../Models/Interfaces/IOpenApiRequestBody.cs | 8 +- .../Models/Interfaces/IOpenApiResponse.cs | 8 +- .../Models/Interfaces/IOpenApiSchema.cs | 60 +- .../Interfaces/IOpenApiSecurityScheme.cs | 12 +- .../Interfaces/IOpenApiSummarizedElement.cs | 4 +- .../Models/Interfaces/IOpenApiTag.cs | 6 +- .../Models/OpenApiCallback.cs | 13 +- .../Models/OpenApiContact.cs | 8 +- .../Models/OpenApiDiscriminator.cs | 6 +- .../Models/OpenApiDocument.cs | 157 ++-- .../Models/OpenApiEncoding.cs | 6 +- src/Microsoft.OpenApi/Models/OpenApiError.cs | 4 +- .../Models/OpenApiExample.cs | 10 +- .../Models/OpenApiExtensibleDictionary.cs | 6 +- .../Models/OpenApiExternalDocs.cs | 8 +- src/Microsoft.OpenApi/Models/OpenApiHeader.cs | 16 +- src/Microsoft.OpenApi/Models/OpenApiInfo.cs | 24 +- .../Models/OpenApiLicense.cs | 10 +- src/Microsoft.OpenApi/Models/OpenApiLink.cs | 14 +- .../Models/OpenApiOAuthFlow.cs | 12 +- .../Models/OpenApiOAuthFlows.cs | 20 +- .../Models/OpenApiOperation.cs | 21 +- .../Models/OpenApiParameter.cs | 22 +- .../Models/OpenApiPathItem.cs | 39 +- .../Models/OpenApiReference.cs | 63 +- .../Models/OpenApiRequestBody.cs | 75 +- .../Models/OpenApiResponse.cs | 30 +- src/Microsoft.OpenApi/Models/OpenApiSchema.cs | 96 ++- .../Models/OpenApiSecurityRequirement.cs | 21 +- .../Models/OpenApiSecurityScheme.cs | 22 +- src/Microsoft.OpenApi/Models/OpenApiServer.cs | 10 +- .../Models/OpenApiServerVariable.cs | 22 +- src/Microsoft.OpenApi/Models/OpenApiTag.cs | 8 +- src/Microsoft.OpenApi/Models/OpenApiXml.cs | 10 +- .../References/BaseOpenApiReferenceHolder.cs | 24 +- .../References/OpenApiCallbackReference.cs | 6 +- .../References/OpenApiExampleReference.cs | 32 +- .../References/OpenApiHeaderReference.cs | 24 +- .../Models/References/OpenApiLinkReference.cs | 26 +- .../References/OpenApiParameterReference.cs | 28 +- .../References/OpenApiPathItemReference.cs | 34 +- .../References/OpenApiRequestBodyReference.cs | 34 +- .../References/OpenApiResponseReference.cs | 22 +- .../References/OpenApiSchemaReference.cs | 76 +- .../OpenApiSecuritySchemeReference.cs | 26 +- .../Models/References/OpenApiTagReference.cs | 14 +- .../Models/RuntimeExpressionAnyWrapper.cs | 8 +- .../Reader/JsonNodeHelper.cs | 2 +- .../Reader/OpenApiDiagnostic.cs | 2 +- .../Reader/OpenApiJsonReader.cs | 59 +- .../Reader/OpenApiModelFactory.cs | 58 +- .../Reader/OpenApiReaderSettings.cs | 15 +- .../Reader/ParseNodes/AnyFieldMapParameter.cs | 12 +- .../ParseNodes/AnyListFieldMapParameter.cs | 4 +- .../ParseNodes/AnyMapFieldMapParameter.cs | 12 +- .../ParseNodes/JsonPointerExtensions.cs | 4 +- .../Reader/ParseNodes/ListNode.cs | 17 +- .../Reader/ParseNodes/MapNode.cs | 55 +- .../Reader/ParseNodes/ParseNode.cs | 6 +- .../Reader/ParseNodes/RootNode.cs | 4 +- .../Reader/ParseNodes/ValueNode.cs | 7 +- .../Reader/ParsingContext.cs | 26 +- src/Microsoft.OpenApi/Reader/ReadResult.cs | 6 +- .../OpenApiRemoteReferenceCollector.cs | 8 +- .../Reader/Services/OpenApiWorkspaceLoader.cs | 19 +- .../Reader/V2/OpenApiContactDeserializer.cs | 11 +- .../Reader/V2/OpenApiDocumentDeserializer.cs | 55 +- .../V2/OpenApiExternalDocsDeserializer.cs | 20 +- .../Reader/V2/OpenApiHeaderDeserializer.cs | 92 +- .../Reader/V2/OpenApiInfoDeserializer.cs | 11 +- .../Reader/V2/OpenApiLicenseDeserializer.cs | 9 +- .../Reader/V2/OpenApiOperationDeserializer.cs | 50 +- .../Reader/V2/OpenApiParameterDeserializer.cs | 104 ++- .../Reader/V2/OpenApiPathItemDeserializer.cs | 9 +- .../Reader/V2/OpenApiResponseDeserializer.cs | 14 +- .../Reader/V2/OpenApiSchemaDeserializer.cs | 125 ++- .../OpenApiSecurityRequirementDeserializer.cs | 7 +- .../V2/OpenApiSecuritySchemeDeserializer.cs | 37 +- .../Reader/V2/OpenApiV2Deserializer.cs | 18 +- .../Reader/V2/OpenApiV2VersionService.cs | 169 +--- .../Reader/V2/OpenApiXmlDeserializer.cs | 23 +- .../Reader/V3/OpenApiContactDeserializer.cs | 9 +- .../V3/OpenApiDiscriminatorDeserializer.cs | 3 +- .../Reader/V3/OpenApiDocumentDeserializer.cs | 2 +- .../Reader/V3/OpenApiEncodingDeserializer.cs | 18 +- .../V3/OpenApiExternalDocsDeserializer.cs | 11 +- .../Reader/V3/OpenApiHeaderDeserializer.cs | 45 +- .../Reader/V3/OpenApiInfoDeserializer.cs | 9 +- .../Reader/V3/OpenApiLicenseDeserializer.cs | 9 +- .../Reader/V3/OpenApiMediaTypeDeserializer.cs | 4 +- .../Reader/V3/OpenApiOAuthFlowDeserializer.cs | 30 +- .../Reader/V3/OpenApiOperationDeserializer.cs | 11 +- .../Reader/V3/OpenApiParameterDeserializer.cs | 45 +- .../V3/OpenApiRequestBodyDeserializer.cs | 9 +- .../Reader/V3/OpenApiSchemaDeserializer.cs | 130 ++- .../OpenApiSecurityRequirementDeserializer.cs | 7 +- .../V3/OpenApiSecuritySchemeDeserializer.cs | 11 +- .../V3/OpenApiServerVariableDeserializer.cs | 3 +- .../Reader/V3/OpenApiV3Deserializer.cs | 78 +- .../Reader/V3/OpenApiV3VersionService.cs | 139 +-- .../Reader/V3/OpenApiXmlDeserializer.cs | 27 +- .../Reader/V31/OpenApiContactDeserializer.cs | 9 +- .../V31/OpenApiDiscriminatorDeserializer.cs | 3 +- .../Reader/V31/OpenApiDocumentDeserializer.cs | 2 +- .../Reader/V31/OpenApiEncodingDeserializer.cs | 12 +- .../V31/OpenApiExternalDocsDeserializer.cs | 9 +- .../Reader/V31/OpenApiHeaderDeserializer.cs | 45 +- .../Reader/V31/OpenApiInfoDeserializer.cs | 9 +- .../Reader/V31/OpenApiLicenseDeserializer.cs | 11 +- .../V31/OpenApiOAuthFlowDeserializer.cs | 30 +- .../V31/OpenApiOperationDeserializer.cs | 11 +- .../V31/OpenApiParameterDeserializer.cs | 42 +- .../V31/OpenApiRequestBodyDeserializer.cs | 6 +- .../Reader/V31/OpenApiSchemaDeserializer.cs | 161 +++- .../OpenApiSecurityRequirementDeserializer.cs | 10 +- .../V31/OpenApiSecuritySchemeDeserializer.cs | 8 +- .../V31/OpenApiServerVariableDeserializer.cs | 3 +- .../Reader/V31/OpenApiV31Deserializer.cs | 29 +- .../Reader/V31/OpenApiV31VersionService.cs | 123 +-- .../Reader/V31/OpenApiXmlDeserializer.cs | 35 +- .../Services/CopyReferences.cs | 112 ++- .../Services/LoopDetector.cs | 7 +- .../Services/OpenApiFilterService.cs | 173 ++-- .../Services/OpenApiReferenceError.cs | 2 +- .../Services/OpenApiUrlTreeNode.cs | 8 +- .../Services/OpenApiWalker.cs | 84 +- .../Services/OpenApiWorkspace.cs | 153 ++-- .../Services/OperationSearch.cs | 25 +- .../Services/SearchResult.cs | 6 +- .../Validations/IValidationContext.cs | 5 - .../Validations/OpenApiValidator.cs | 20 +- .../Rules/OpenApiComponentsRules.cs | 2 +- .../Rules/OpenApiExtensionRules.cs | 13 +- .../Rules/OpenApiNonDefaultRules.cs | 6 +- .../Validations/Rules/OpenApiSchemaRules.cs | 60 +- .../Validations/Rules/OpenApiServerRules.cs | 13 +- .../Validations/Rules/RuleHelpers.cs | 8 +- .../Validations/ValidationRuleSet.cs | 15 +- .../Writers/OpenApiJsonWriter.cs | 12 +- .../Writers/OpenApiWriterAnyExtensions.cs | 31 +- .../Writers/OpenApiWriterBase.cs | 9 +- .../Writers/OpenApiWriterExtensions.cs | 30 +- .../Writers/OpenApiYamlWriter.cs | 29 +- .../Formatters/PowerShellFormatterTests.cs | 22 +- .../Services/OpenApiFilterServiceTests.cs | 93 +- .../UtilityFiles/OpenApiDocumentMock.cs | 34 +- .../ParseNodeTests.cs | 2 +- .../ConvertToOpenApiReferenceV2Tests.cs | 128 --- .../ConvertToOpenApiReferenceV3Tests.cs | 145 ---- .../Models/OpenApiReferenceTests.cs | 16 +- .../PublicApi/PublicApi.approved.txt | 801 +++++++++--------- .../Walkers/WalkerLocationTests.cs | 3 +- 194 files changed, 3113 insertions(+), 2805 deletions(-) delete mode 100644 test/Microsoft.OpenApi.Readers.Tests/ReferenceService/ConvertToOpenApiReferenceV2Tests.cs delete mode 100644 test/Microsoft.OpenApi.Readers.Tests/ReferenceService/ConvertToOpenApiReferenceV3Tests.cs diff --git a/src/Microsoft.OpenApi.Hidi/Formatters/PowerShellFormatter.cs b/src/Microsoft.OpenApi.Hidi/Formatters/PowerShellFormatter.cs index f263dae0e..b46e0b2a6 100644 --- a/src/Microsoft.OpenApi.Hidi/Formatters/PowerShellFormatter.cs +++ b/src/Microsoft.OpenApi.Hidi/Formatters/PowerShellFormatter.cs @@ -54,7 +54,7 @@ public override void Visit(IOpenApiSchema schema) public override void Visit(IOpenApiPathItem pathItem) { - if (pathItem.Operations.TryGetValue(HttpMethod.Put, out var value) && + if (pathItem.Operations is not null && pathItem.Operations.TryGetValue(HttpMethod.Put, out var value) && value.OperationId != null) { var operationId = value.OperationId; @@ -150,7 +150,7 @@ private static string RemoveKeyTypeSegment(string operationId, IList parameter private void AddAdditionalPropertiesToSchema(IOpenApiSchema schema) { - if (schema is OpenApiSchema openApiSchema && !_schemaLoop.Contains(schema) && schema.Type.Equals(JsonSchemaType.Object)) + if (schema is OpenApiSchema openApiSchema + && !_schemaLoop.Contains(schema) + && schema.Type.Equals(JsonSchemaType.Object)) { openApiSchema.AdditionalProperties = new OpenApiSchema() { Type = JsonSchemaType.Object }; @@ -187,7 +189,10 @@ private void AddAdditionalPropertiesToSchema(IOpenApiSchema schema) * we need a way to keep track of visited schemas to avoid * endlessly creating and walking them in an infinite recursion. */ - _schemaLoop.Push(schema.AdditionalProperties); + if (schema.AdditionalProperties is not null) + { + _schemaLoop.Push(schema.AdditionalProperties); + } } } diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index e0cce5896..7cdf9a2cb 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -94,7 +94,7 @@ public static async Task TransformOpenApiDocumentAsync(HidiOptions options, ILog // Load OpenAPI document var document = await GetOpenApiAsync(options, openApiFormat.GetDisplayName(), logger, options.MetadataVersion, cancellationToken).ConfigureAwait(false); - if (options.FilterOptions != null) + if (options.FilterOptions != null && document is not null) { document = ApplyFilters(options, logger, apiDependency, postmanCollection, document); } @@ -107,7 +107,11 @@ public static async Task TransformOpenApiDocumentAsync(HidiOptions options, ILog var walker = new OpenApiWalker(powerShellFormatter); walker.Walk(document); } - await WriteOpenApiAsync(options, openApiFormat, openApiVersion, document, logger, cancellationToken).ConfigureAwait(false); + if (document is not null) + { + // Write the OpenAPI document to the output file + await WriteOpenApiAsync(options, openApiFormat, openApiVersion, document, logger, cancellationToken).ConfigureAwait(false); + } } catch (TaskCanceledException) { @@ -172,7 +176,7 @@ private static OpenApiDocument ApplyFilters(HidiOptions options, ILogger logger, options.FilterOptions.FilterByTags, requestUrls, document, - logger); + logger); if (predicate != null) { var stopwatch = new Stopwatch(); @@ -210,6 +214,7 @@ private static async Task WriteOpenApiAsync(HidiOptions options, OpenApiFormat o var stopwatch = new Stopwatch(); stopwatch.Start(); + await document.SerializeAsync(writer, openApiVersion, cancellationToken).ConfigureAwait(false); stopwatch.Stop(); @@ -219,9 +224,9 @@ private static async Task WriteOpenApiAsync(HidiOptions options, OpenApiFormat o } // Get OpenAPI document either from OpenAPI or CSDL - private static async Task GetOpenApiAsync(HidiOptions options, string format, ILogger logger, string? metadataVersion = null, CancellationToken cancellationToken = default) + private static async Task GetOpenApiAsync(HidiOptions options, string format, ILogger logger, string? metadataVersion = null, CancellationToken cancellationToken = default) { - OpenApiDocument document; + OpenApiDocument? document; Stream stream; if (!string.IsNullOrEmpty(options.Csdl)) @@ -242,7 +247,7 @@ private static async Task GetOpenApiAsync(HidiOptions options, document = await ConvertCsdlToOpenApiAsync(filteredStream ?? stream, format, metadataVersion, options.SettingsConfig, cancellationToken).ConfigureAwait(false); stopwatch.Stop(); - logger.LogTrace("{Timestamp}ms: Generated OpenAPI with {Paths} paths.", stopwatch.ElapsedMilliseconds, document.Paths.Count); + logger.LogTrace("{Timestamp}ms: Generated OpenAPI with {Paths} paths.", stopwatch.ElapsedMilliseconds, document?.Paths.Count); } } else if (!string.IsNullOrEmpty(options.OpenApi)) @@ -370,7 +375,7 @@ private static MemoryStream ApplyFilterToCsdl(Stream csdlStream, string entitySe if (result is null) return null; - return result.Diagnostic.Errors.Count == 0; + return result.Diagnostic?.Errors.Count == 0; } private static async Task ParseOpenApiAsync(string openApiFile, bool inlineExternal, ILogger logger, Stream stream, CancellationToken cancellationToken = default) @@ -407,7 +412,7 @@ private static async Task ParseOpenApiAsync(string openApiFile, bool ///
/// The CSDL stream. /// An OpenAPI document. - public static async Task ConvertCsdlToOpenApiAsync(Stream csdl, string format, string? metadataVersion = null, IConfiguration? settings = null, CancellationToken token = default) + public static async Task ConvertCsdlToOpenApiAsync(Stream csdl, string format, string? metadataVersion = null, IConfiguration? settings = null, CancellationToken token = default) { using var reader = new StreamReader(csdl); var csdlText = await reader.ReadToEndAsync(token).ConfigureAwait(false); @@ -425,7 +430,7 @@ public static async Task ConvertCsdlToOpenApiAsync(Stream csdl, ///
/// The converted OpenApiDocument. /// A valid OpenApiDocument instance. - public static OpenApiDocument FixReferences(OpenApiDocument document, string format) + public static OpenApiDocument? FixReferences(OpenApiDocument document, string format) { // This method is only needed because the output of ConvertToOpenApi isn't quite a valid OpenApiDocument instance. // So we write it out, and read it back in again to fix it up. @@ -584,52 +589,54 @@ private static string GetInputPathExtension(string? openapi = null, string? csdl var openApiFormat = options.OpenApiFormat ?? (!string.IsNullOrEmpty(options.OpenApi) ? GetOpenApiFormat(options.OpenApi, logger) : OpenApiFormat.Yaml); var document = await GetOpenApiAsync(options, openApiFormat.GetDisplayName(), logger, null, cancellationToken).ConfigureAwait(false); - - using (logger.BeginScope("Creating diagram")) + if (document is not null) { - // If output is null, create a HTML file in the user's temporary directory - var sourceUrl = (string.IsNullOrEmpty(options.OpenApi), string.IsNullOrEmpty(options.Csdl)) switch { - (false, _) => options.OpenApi!, - (_, false) => options.Csdl!, - _ => throw new InvalidOperationException("No input file path or URL provided") - }; - if (options.Output == null) + using (logger.BeginScope("Creating diagram")) { - var tempPath = Path.GetTempPath() + "/hidi/"; - if (!File.Exists(tempPath)) + // If output is null, create a HTML file in the user's temporary directory + var sourceUrl = (string.IsNullOrEmpty(options.OpenApi), string.IsNullOrEmpty(options.Csdl)) switch { - Directory.CreateDirectory(tempPath); - } - - var fileName = Path.GetRandomFileName(); - - var output = new FileInfo(Path.Combine(tempPath, fileName + ".html")); - using (var file = new FileStream(output.FullName, FileMode.Create)) + (false, _) => options.OpenApi!, + (_, false) => options.Csdl!, + _ => throw new InvalidOperationException("No input file path or URL provided") + }; + if (options.Output == null) { - using var writer = new StreamWriter(file); - WriteTreeDocumentAsHtml(sourceUrl, document, writer); + var tempPath = Path.GetTempPath() + "/hidi/"; + if (!File.Exists(tempPath)) + { + Directory.CreateDirectory(tempPath); + } + + var fileName = Path.GetRandomFileName(); + + var output = new FileInfo(Path.Combine(tempPath, fileName + ".html")); + using (var file = new FileStream(output.FullName, FileMode.Create)) + { + using var writer = new StreamWriter(file); + WriteTreeDocumentAsHtml(sourceUrl, document, writer); + } + logger.LogTrace("Created Html document with diagram "); + + // Launch a browser to display the output html file + using var process = new Process(); + process.StartInfo.FileName = output.FullName; + process.StartInfo.UseShellExecute = true; + process.Start(); + + return output.FullName; } - logger.LogTrace("Created Html document with diagram "); - - // Launch a browser to display the output html file - using var process = new Process(); - process.StartInfo.FileName = output.FullName; - process.StartInfo.UseShellExecute = true; - process.Start(); - - return output.FullName; - } - else // Write diagram as Markdown document to output file - { - using (var file = new FileStream(options.Output.FullName, FileMode.Create)) + else // Write diagram as Markdown document to output file { + using var file = new FileStream(options.Output.FullName, FileMode.Create); using var writer = new StreamWriter(file); WriteTreeDocumentAsMarkdown(sourceUrl, document, writer); + + logger.LogTrace("Created markdown document with diagram "); + return options.Output.FullName; } - logger.LogTrace("Created markdown document with diagram "); - return options.Output.FullName; } - } + } } catch (TaskCanceledException) { @@ -645,7 +652,7 @@ private static string GetInputPathExtension(string? openapi = null, string? csdl private static void LogErrors(ILogger logger, ReadResult result) { var context = result.Diagnostic; - if (context.Errors.Count != 0) + if (context is not null && context.Errors.Count != 0) { using (logger.BeginScope("Detected errors")) { @@ -697,7 +704,7 @@ internal static void WriteTreeDocumentAsHtml(string sourceUrl, OpenApiDocument d """); - writer.WriteLine("

" + document.Info.Title + "

"); + writer.WriteLine("

" + document?.Info.Title + "

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

API Description: {sourceUrl}

"); @@ -751,7 +758,7 @@ internal static async Task PluginManifestAsync(HidiOptions options, ILogger logg cancellationToken.ThrowIfCancellationRequested(); - if (options.FilterOptions != null) + if (options.FilterOptions != null && document is not null) { document = ApplyFilters(options, logger, apiDependency, null, document); } @@ -765,24 +772,31 @@ internal static async Task PluginManifestAsync(HidiOptions options, ILogger logg // Write OpenAPI to Output folder options.Output = new(Path.Combine(options.OutputFolder, "openapi.json")); options.TerseOutput = true; - await WriteOpenApiAsync(options, OpenApiFormat.Json, OpenApiSpecVersion.OpenApi3_1, document, logger, cancellationToken).ConfigureAwait(false); - - // Create OpenAIPluginManifest from ApiDependency and OpenAPI document - var manifest = new OpenAIPluginManifest(document.Info?.Title ?? "Title", document.Info?.Title ?? "Title", "https://go.microsoft.com/fwlink/?LinkID=288890", document.Info?.Contact?.Email ?? "placeholder@contoso.com", document.Info?.License?.Url.ToString() ?? "https://placeholderlicenseurl.com") - { - DescriptionForHuman = document.Info?.Description ?? "Description placeholder", - Api = new("openapi", "./openapi.json"), - Auth = new ManifestNoAuth(), - }; - manifest.NameForModel = manifest.NameForHuman; - manifest.DescriptionForModel = manifest.DescriptionForHuman; - - // Write OpenAIPluginManifest to Output folder - var manifestFile = new FileInfo(Path.Combine(options.OutputFolder, "ai-plugin.json")); - using var file = new FileStream(manifestFile.FullName, FileMode.Create); - using var jsonWriter = new Utf8JsonWriter(file, new() { Indented = true }); - manifest.Write(jsonWriter); - await jsonWriter.FlushAsync(cancellationToken).ConfigureAwait(false); + if (document is not null) + { + await WriteOpenApiAsync(options, OpenApiFormat.Json, OpenApiSpecVersion.OpenApi3_1, document, logger, cancellationToken).ConfigureAwait(false); + + // Create OpenAIPluginManifest from ApiDependency and OpenAPI document + var manifest = new OpenAIPluginManifest(document.Info.Title ?? "Title", + document.Info.Title ?? "Title", + "https://go.microsoft.com/fwlink/?LinkID=288890", + document.Info?.Contact?.Email ?? "placeholder@contoso.com", + document.Info?.License?.Url?.ToString() ?? "https://placeholderlicenseurl.com") + { + DescriptionForHuman = document.Info?.Description ?? "Description placeholder", + Api = new("openapi", "./openapi.json"), + Auth = new ManifestNoAuth(), + }; + manifest.NameForModel = manifest.NameForHuman; + manifest.DescriptionForModel = manifest.DescriptionForHuman; + + // Write OpenAIPluginManifest to Output folder + var manifestFile = new FileInfo(Path.Combine(options.OutputFolder, "ai-plugin.json")); + using var file = new FileStream(manifestFile.FullName, FileMode.Create); + using var jsonWriter = new Utf8JsonWriter(file, new() { Indented = true }); + manifest.Write(jsonWriter); + await jsonWriter.FlushAsync(cancellationToken).ConfigureAwait(false); + } } } } diff --git a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj index e3a40ffb7..8e55c6487 100644 --- a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj +++ b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj @@ -11,6 +11,7 @@ true NU5048 + enable README.md diff --git a/src/Microsoft.OpenApi.Readers/OpenApiYamlReader.cs b/src/Microsoft.OpenApi.Readers/OpenApiYamlReader.cs index eba4fd248..d52be9a4a 100644 --- a/src/Microsoft.OpenApi.Readers/OpenApiYamlReader.cs +++ b/src/Microsoft.OpenApi.Readers/OpenApiYamlReader.cs @@ -84,11 +84,11 @@ public static ReadResult Read(JsonNode jsonNode, OpenApiReaderSettings settings) } /// - public T ReadFragment(MemoryStream input, + public T? ReadFragment(MemoryStream input, OpenApiSpecVersion version, OpenApiDocument openApiDocument, out OpenApiDiagnostic diagnostic, - OpenApiReaderSettings settings = null) where T : IOpenApiElement + OpenApiReaderSettings? settings = null) where T : IOpenApiElement { if (input is null) throw new ArgumentNullException(nameof(input)); JsonNode jsonNode; @@ -110,7 +110,7 @@ public T ReadFragment(MemoryStream input, } /// - public static T ReadFragment(JsonNode input, OpenApiSpecVersion version, OpenApiDocument openApiDocument, out OpenApiDiagnostic diagnostic, OpenApiReaderSettings settings = null) where T : IOpenApiElement + public static T? ReadFragment(JsonNode input, OpenApiSpecVersion version, OpenApiDocument openApiDocument, out OpenApiDiagnostic diagnostic, OpenApiReaderSettings? settings = null) where T : IOpenApiElement { return _jsonReader.ReadFragment(input, version, openApiDocument, out diagnostic, settings); } diff --git a/src/Microsoft.OpenApi/Exceptions/OpenApiException.cs b/src/Microsoft.OpenApi/Exceptions/OpenApiException.cs index 9c1f4233f..cb7eaecf0 100644 --- a/src/Microsoft.OpenApi/Exceptions/OpenApiException.cs +++ b/src/Microsoft.OpenApi/Exceptions/OpenApiException.cs @@ -33,7 +33,7 @@ public OpenApiException(string message) ///
/// The plain text error message for this exception. /// The inner exception that is the cause of this exception to be thrown. - public OpenApiException(string message, Exception innerException) + public OpenApiException(string message, Exception? innerException) : base(message, innerException) { } @@ -46,6 +46,6 @@ public OpenApiException(string message, Exception innerException) /// 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; } + public string? Pointer { get; set; } } } diff --git a/src/Microsoft.OpenApi/Exceptions/OpenApiReaderException.cs b/src/Microsoft.OpenApi/Exceptions/OpenApiReaderException.cs index 257b0e9a4..aa7866c02 100644 --- a/src/Microsoft.OpenApi/Exceptions/OpenApiReaderException.cs +++ b/src/Microsoft.OpenApi/Exceptions/OpenApiReaderException.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System; @@ -34,17 +34,6 @@ public OpenApiReaderException(string message, ParsingContext context) : base(mes Pointer = context.GetLocation(); } - /// - /// Initializes the class with a message and line, column location of error. - /// - /// Plain text error message for this exception. - /// Parsing node where error occured - public OpenApiReaderException(string message, JsonNode node) : base(message) - { - // This only includes line because using a char range causes tests to break due to CR/LF & LF differences - // See https://tools.ietf.org/html/rfc5147 for syntax - } - /// /// Initializes the class with a custom message and inner exception. /// diff --git a/src/Microsoft.OpenApi/Exceptions/OpenApiWriterException.cs b/src/Microsoft.OpenApi/Exceptions/OpenApiWriterException.cs index 9e0540c53..af19269f8 100644 --- a/src/Microsoft.OpenApi/Exceptions/OpenApiWriterException.cs +++ b/src/Microsoft.OpenApi/Exceptions/OpenApiWriterException.cs @@ -33,7 +33,7 @@ public OpenApiWriterException(string message) /// /// The plain text error message for this exception. /// The inner exception that is the cause of this exception to be thrown. - public OpenApiWriterException(string message, Exception innerException) + public OpenApiWriterException(string message, Exception? innerException) : base(message, innerException) { } diff --git a/src/Microsoft.OpenApi/Expressions/BodyExpression.cs b/src/Microsoft.OpenApi/Expressions/BodyExpression.cs index c63b1bc58..a6743e715 100644 --- a/src/Microsoft.OpenApi/Expressions/BodyExpression.cs +++ b/src/Microsoft.OpenApi/Expressions/BodyExpression.cs @@ -30,7 +30,7 @@ public BodyExpression() /// Initializes a new instance of the class. /// /// a JSON Pointer [RFC 6901](https://tools.ietf.org/html/rfc6901). - public BodyExpression(JsonPointer pointer) + public BodyExpression(JsonPointer? pointer) : base(pointer?.ToString()) { Utils.CheckArgumentNull(pointer); @@ -55,6 +55,6 @@ public override string Expression /// /// Gets the fragment string. /// - public string Fragment { get => Value; } + public string? Fragment { get => Value; } } } diff --git a/src/Microsoft.OpenApi/Expressions/HeaderExpression.cs b/src/Microsoft.OpenApi/Expressions/HeaderExpression.cs index 99bbf2a96..f373960d5 100644 --- a/src/Microsoft.OpenApi/Expressions/HeaderExpression.cs +++ b/src/Microsoft.OpenApi/Expressions/HeaderExpression.cs @@ -31,6 +31,6 @@ public HeaderExpression(string token) /// /// Gets the token string. /// - public string Token { get => Value; } + public string? Token { get => Value; } } } diff --git a/src/Microsoft.OpenApi/Expressions/PathExpression.cs b/src/Microsoft.OpenApi/Expressions/PathExpression.cs index 1d43b9b21..9922b6b1f 100644 --- a/src/Microsoft.OpenApi/Expressions/PathExpression.cs +++ b/src/Microsoft.OpenApi/Expressions/PathExpression.cs @@ -31,6 +31,6 @@ public PathExpression(string name) /// /// Gets the name string. /// - public string Name { get => Value; } + public string? Name { get => Value; } } } diff --git a/src/Microsoft.OpenApi/Expressions/QueryExpression.cs b/src/Microsoft.OpenApi/Expressions/QueryExpression.cs index 55016d82a..d33f3bff6 100644 --- a/src/Microsoft.OpenApi/Expressions/QueryExpression.cs +++ b/src/Microsoft.OpenApi/Expressions/QueryExpression.cs @@ -31,6 +31,6 @@ public QueryExpression(string name) /// /// Gets the name string. /// - public string Name { get => Value; } + public string? Name { get => Value; } } } diff --git a/src/Microsoft.OpenApi/Expressions/RuntimeExpression.cs b/src/Microsoft.OpenApi/Expressions/RuntimeExpression.cs index 69aecfd37..b6104e1b3 100644 --- a/src/Microsoft.OpenApi/Expressions/RuntimeExpression.cs +++ b/src/Microsoft.OpenApi/Expressions/RuntimeExpression.cs @@ -84,7 +84,7 @@ public override int GetHashCode() /// /// Equals implementation for IEquatable. /// - public override bool Equals(object obj) + public override bool Equals(object? obj) { return Equals(obj as RuntimeExpression); } @@ -92,7 +92,7 @@ public override bool Equals(object obj) /// /// Equals implementation for object of the same type. /// - public bool Equals(RuntimeExpression obj) + public bool Equals(RuntimeExpression? obj) { return obj != null && obj.Expression == Expression; } diff --git a/src/Microsoft.OpenApi/Expressions/SourceExpression.cs b/src/Microsoft.OpenApi/Expressions/SourceExpression.cs index 76a22f97d..36eec56f7 100644 --- a/src/Microsoft.OpenApi/Expressions/SourceExpression.cs +++ b/src/Microsoft.OpenApi/Expressions/SourceExpression.cs @@ -16,7 +16,7 @@ public abstract class SourceExpression : RuntimeExpression /// Initializes a new instance of the class. /// /// The value string. - protected SourceExpression(string value) + protected SourceExpression(string? value) { Value = value; } @@ -24,7 +24,7 @@ protected SourceExpression(string value) /// /// Gets the expression string. /// - protected string Value { get; } + protected string? Value { get; } /// /// Build the source expression from input string. diff --git a/src/Microsoft.OpenApi/Extensions/EnumExtensions.cs b/src/Microsoft.OpenApi/Extensions/EnumExtensions.cs index bc4e86783..d3ada8f1e 100644 --- a/src/Microsoft.OpenApi/Extensions/EnumExtensions.cs +++ b/src/Microsoft.OpenApi/Extensions/EnumExtensions.cs @@ -27,7 +27,7 @@ public static class EnumExtensions /// The attribute of the specified type or null. /// [UnconditionalSuppressMessage("Trimming", "IL2075", Justification = "Fields are never trimmed for enum types.")] - public static T GetAttributeOfType(this Enum enumValue) where T : Attribute + public static T? GetAttributeOfType(this Enum enumValue) where T : Attribute { var type = enumValue.GetType(); // Use GetField to get the field info for the enum value @@ -58,7 +58,7 @@ public static string GetDisplayName(this Enum enumValue) var attribute = e.GetAttributeOfType(); // Return the DisplayAttribute name if it exists, otherwise return the enum's string representation - return attribute == null ? e.ToString() : attribute.Name; + return attribute?.Name is not null ? attribute.Name : e.ToString(); }); } } diff --git a/src/Microsoft.OpenApi/Extensions/OpenApiElementExtensions.cs b/src/Microsoft.OpenApi/Extensions/OpenApiElementExtensions.cs index d0b0d9c35..e44b90be8 100644 --- a/src/Microsoft.OpenApi/Extensions/OpenApiElementExtensions.cs +++ b/src/Microsoft.OpenApi/Extensions/OpenApiElementExtensions.cs @@ -23,13 +23,7 @@ public static class OpenApiElementExtensions /// An IEnumerable of errors. This function will never return null. public static IEnumerable Validate(this IOpenApiElement element, ValidationRuleSet ruleSet) { - var validator = new OpenApiValidator(ruleSet); - - if (element is OpenApiDocument doc) - { - validator.HostDocument = doc; - } - + var validator = new OpenApiValidator(ruleSet); var walker = new OpenApiWalker(validator); walker.Walk(element); return validator.Errors.Cast().Union(validator.Warnings); diff --git a/src/Microsoft.OpenApi/Extensions/OpenApiExtensibleExtensions.cs b/src/Microsoft.OpenApi/Extensions/OpenApiExtensibleExtensions.cs index c8c3b2a48..01fc02020 100644 --- a/src/Microsoft.OpenApi/Extensions/OpenApiExtensibleExtensions.cs +++ b/src/Microsoft.OpenApi/Extensions/OpenApiExtensibleExtensions.cs @@ -32,7 +32,10 @@ public static void AddExtension(this T element, string name, IOpenApiExtensio throw new OpenApiException(string.Format(SRResource.ExtensionFieldNameMustBeginWithXDash, name)); } - element.Extensions[name] = Utils.CheckArgumentNull(any); + if (element.Extensions is not null) + { + element.Extensions[name] = Utils.CheckArgumentNull(any); + } } } } diff --git a/src/Microsoft.OpenApi/Extensions/OpenApiReferencableExtensions.cs b/src/Microsoft.OpenApi/Extensions/OpenApiReferencableExtensions.cs index da51f3b55..df266b577 100644 --- a/src/Microsoft.OpenApi/Extensions/OpenApiReferencableExtensions.cs +++ b/src/Microsoft.OpenApi/Extensions/OpenApiReferencableExtensions.cs @@ -32,17 +32,20 @@ public static IOpenApiReferenceable ResolveReference(this IOpenApiReferenceable var mapKey = pointer.Tokens.ElementAtOrDefault(1); try { - if (element is OpenApiHeader header) + if (propertyName is not null && mapKey is not null) { - return ResolveReferenceOnHeaderElement(header, propertyName, mapKey, pointer); - } - if (element is OpenApiParameter parameter) - { - return ResolveReferenceOnParameterElement(parameter, propertyName, mapKey, pointer); - } - if (element is OpenApiResponse response) - { - return ResolveReferenceOnResponseElement(response, propertyName, mapKey, pointer); + if (element is OpenApiHeader header) + { + return ResolveReferenceOnHeaderElement(header, propertyName, mapKey, pointer); + } + if (element is OpenApiParameter parameter) + { + return ResolveReferenceOnParameterElement(parameter, propertyName, mapKey, pointer); + } + if (element is OpenApiResponse response) + { + return ResolveReferenceOnResponseElement(response, propertyName, mapKey, pointer); + } } } catch (KeyNotFoundException) diff --git a/src/Microsoft.OpenApi/Extensions/OpenApiSerializableExtensions.cs b/src/Microsoft.OpenApi/Extensions/OpenApiSerializableExtensions.cs index 9d284db1a..d028cd5e4 100755 --- a/src/Microsoft.OpenApi/Extensions/OpenApiSerializableExtensions.cs +++ b/src/Microsoft.OpenApi/Extensions/OpenApiSerializableExtensions.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System.Globalization; @@ -82,7 +82,7 @@ public static Task SerializeAsync( Stream stream, OpenApiSpecVersion specVersion, OpenApiFormat format, - OpenApiWriterSettings settings, + OpenApiWriterSettings? settings = null, CancellationToken cancellationToken = default) where T : IOpenApiSerializable { diff --git a/src/Microsoft.OpenApi/Extensions/OpenApiServerExtensions.cs b/src/Microsoft.OpenApi/Extensions/OpenApiServerExtensions.cs index b885cb235..5276876ce 100644 --- a/src/Microsoft.OpenApi/Extensions/OpenApiServerExtensions.cs +++ b/src/Microsoft.OpenApi/Extensions/OpenApiServerExtensions.cs @@ -21,37 +21,39 @@ public static class OpenApiServerExtensions /// 1. A substitution has no valid value in both the supplied dictionary and the default /// 2. A substitution's value is not available in the enum provided /// - public static string ReplaceServerUrlVariables(this OpenApiServer server, IDictionary values = null) + public static string? ReplaceServerUrlVariables(this OpenApiServer server, IDictionary? values = null) { var parsedUrl = server.Url; - foreach (var variable in server.Variables) + if (server.Variables is not null && parsedUrl is not null) { - // Try to get the value from the provided values - if (values is not { } v || !v.TryGetValue(variable.Key, out var value) || string.IsNullOrEmpty(value)) + foreach (var variable in server.Variables) { - // Fall back to the default value - value = variable.Value.Default; - } + // Try to get the value from the provided values + if (values is not { } v || !v.TryGetValue(variable.Key, out var value) || string.IsNullOrEmpty(value)) + { + // Fall back to the default value + value = variable.Value.Default; + } - // Validate value - if (string.IsNullOrEmpty(value)) - { - // According to the spec, the variable's default value is required. - // This code path should be hit when a value isn't provided & a default value isn't available - throw new ArgumentException( - string.Format(SRResource.ParseServerUrlDefaultValueNotAvailable, variable.Key), nameof(server)); - } + // Validate value + if (string.IsNullOrEmpty(value)) + { + // According to the spec, the variable's default value is required. + // This code path should be hit when a value isn't provided & a default value isn't available + throw new ArgumentException( + string.Format(SRResource.ParseServerUrlDefaultValueNotAvailable, variable.Key), nameof(server)); + } - // If an enum is provided, the array should not be empty & the value should exist in the enum - if (variable.Value.Enum is {} e && (e.Count == 0 || !e.Contains(value))) - { - throw new ArgumentException( - string.Format(SRResource.ParseServerUrlValueNotValid, value, variable.Key), nameof(values)); - } - - parsedUrl = parsedUrl.Replace($"{{{variable.Key}}}", value); - } + // If an enum is provided, the array should not be empty & the value should exist in the enum + if (value is not null && variable.Value.Enum is { } e && (e.Count == 0 || !e.Contains(value))) + { + throw new ArgumentException( + string.Format(SRResource.ParseServerUrlValueNotValid, value, variable.Key), nameof(values)); + } + parsedUrl = parsedUrl?.Replace($"{{{variable.Key}}}", value); + } + } return parsedUrl; } } diff --git a/src/Microsoft.OpenApi/Extensions/StringExtensions.cs b/src/Microsoft.OpenApi/Extensions/StringExtensions.cs index b644050ab..d88aeda87 100644 --- a/src/Microsoft.OpenApi/Extensions/StringExtensions.cs +++ b/src/Microsoft.OpenApi/Extensions/StringExtensions.cs @@ -19,7 +19,7 @@ internal static class StringExtensions { private static readonly ConcurrentDictionary> EnumDisplayCache = new(); - internal static bool TryGetEnumFromDisplayName<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields)] T>(this string displayName, ParsingContext parsingContext, out T result) where T : Enum + internal static bool TryGetEnumFromDisplayName<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields)] T>(this string? displayName, ParsingContext parsingContext, out T? result) where T : Enum { if (TryGetEnumFromDisplayName(displayName, out result)) { @@ -30,13 +30,13 @@ internal static class StringExtensions return false; } - internal static bool TryGetEnumFromDisplayName<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields)] T>(this string displayName, out T result) where T : Enum + internal static bool TryGetEnumFromDisplayName<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields)] T>(this string? displayName, out T? result) where T : Enum { var type = typeof(T); - var displayMap = EnumDisplayCache.GetOrAdd(type, _=> GetEnumValues(type)); + var displayMap = EnumDisplayCache.GetOrAdd(type, _ => GetEnumValues(type)); - if (displayMap.TryGetValue(displayName, out var cachedValue)) + if (displayName is not null && displayMap.TryGetValue(displayName, out var cachedValue)) { result = (T)cachedValue; return true; @@ -50,12 +50,14 @@ private static ReadOnlyDictionary GetEnumValues([DynamicallyA var result = new Dictionary(StringComparer.OrdinalIgnoreCase); foreach (var field in enumType.GetFields(BindingFlags.Public | BindingFlags.Static)) { - if (field.GetCustomAttribute() is {} displayAttribute) + if (field.GetCustomAttribute() is { } displayAttribute + && field.GetValue(null) is T enumValue + && displayAttribute.Name is not null) { - var enumValue = (T)field.GetValue(null); result.Add(displayAttribute.Name, enumValue); } } + return new ReadOnlyDictionary(result); } internal static string ToFirstCharacterLowerCase(this string input) diff --git a/src/Microsoft.OpenApi/Helpers/JsonNodeCloneHelper.cs b/src/Microsoft.OpenApi/Helpers/JsonNodeCloneHelper.cs index caab84e7b..5daed4b39 100644 --- a/src/Microsoft.OpenApi/Helpers/JsonNodeCloneHelper.cs +++ b/src/Microsoft.OpenApi/Helpers/JsonNodeCloneHelper.cs @@ -7,9 +7,9 @@ namespace Microsoft.OpenApi.Helpers { internal static class JsonNodeCloneHelper { - internal static JsonNode Clone(JsonNode value) + internal static JsonNode? Clone(JsonNode? value) { - return value.DeepClone(); + return value?.DeepClone(); } } } diff --git a/src/Microsoft.OpenApi/Interfaces/IMetadataContainer.cs b/src/Microsoft.OpenApi/Interfaces/IMetadataContainer.cs index 2d8f26220..2ae2248de 100644 --- a/src/Microsoft.OpenApi/Interfaces/IMetadataContainer.cs +++ b/src/Microsoft.OpenApi/Interfaces/IMetadataContainer.cs @@ -14,6 +14,6 @@ public interface IMetadataContainer /// /// A collection of properties associated with the current OpenAPI element. /// - IDictionary Metadata { get; set; } + IDictionary? Metadata { get; set; } } } diff --git a/src/Microsoft.OpenApi/Interfaces/IOpenApiExtensible.cs b/src/Microsoft.OpenApi/Interfaces/IOpenApiExtensible.cs index 5531b1809..fabd1a177 100644 --- a/src/Microsoft.OpenApi/Interfaces/IOpenApiExtensible.cs +++ b/src/Microsoft.OpenApi/Interfaces/IOpenApiExtensible.cs @@ -13,6 +13,6 @@ public interface IOpenApiExtensible : IOpenApiElement /// /// Specification extensions. /// - IDictionary Extensions { get; set; } + IDictionary? Extensions { get; set; } } } diff --git a/src/Microsoft.OpenApi/Interfaces/IOpenApiReadOnlyExtensible.cs b/src/Microsoft.OpenApi/Interfaces/IOpenApiReadOnlyExtensible.cs index 367c84a96..db451d843 100644 --- a/src/Microsoft.OpenApi/Interfaces/IOpenApiReadOnlyExtensible.cs +++ b/src/Microsoft.OpenApi/Interfaces/IOpenApiReadOnlyExtensible.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; namespace Microsoft.OpenApi.Interfaces; @@ -10,6 +10,6 @@ public interface IOpenApiReadOnlyExtensible /// /// Specification extensions. /// - IDictionary Extensions { get; } + IDictionary? Extensions { get; } } diff --git a/src/Microsoft.OpenApi/Interfaces/IOpenApiReader.cs b/src/Microsoft.OpenApi/Interfaces/IOpenApiReader.cs index 3b9c85d2f..687599caa 100644 --- a/src/Microsoft.OpenApi/Interfaces/IOpenApiReader.cs +++ b/src/Microsoft.OpenApi/Interfaces/IOpenApiReader.cs @@ -40,6 +40,6 @@ public interface IOpenApiReader /// Returns diagnostic object containing errors detected during parsing. /// The OpenApiReader settings. /// Instance of newly created IOpenApiElement. - T ReadFragment(MemoryStream input, OpenApiSpecVersion version, OpenApiDocument openApiDocument, out OpenApiDiagnostic diagnostic, OpenApiReaderSettings settings = null) where T : IOpenApiElement; + T? ReadFragment(MemoryStream input, OpenApiSpecVersion version, OpenApiDocument openApiDocument, out OpenApiDiagnostic diagnostic, OpenApiReaderSettings? settings = null) where T : IOpenApiElement; } } diff --git a/src/Microsoft.OpenApi/Interfaces/IOpenApiReferenceHolder.cs b/src/Microsoft.OpenApi/Interfaces/IOpenApiReferenceHolder.cs index 6c3b0df57..37b8cae3f 100644 --- a/src/Microsoft.OpenApi/Interfaces/IOpenApiReferenceHolder.cs +++ b/src/Microsoft.OpenApi/Interfaces/IOpenApiReferenceHolder.cs @@ -15,11 +15,13 @@ public interface IOpenApiReferenceHolder : IOpenApiReferenceHolder whe /// /// Gets the resolved target object. /// - V Target { get; } + V? Target { get; } + /// /// Gets the recursively resolved target object. /// - T RecursiveTarget { get; } + T? RecursiveTarget { get; } + /// /// Copy the reference as a target element with overrides. /// diff --git a/src/Microsoft.OpenApi/Interfaces/IOpenApiVersionService.cs b/src/Microsoft.OpenApi/Interfaces/IOpenApiVersionService.cs index 073962a35..64049483e 100644 --- a/src/Microsoft.OpenApi/Interfaces/IOpenApiVersionService.cs +++ b/src/Microsoft.OpenApi/Interfaces/IOpenApiVersionService.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using Microsoft.OpenApi.Models; @@ -11,16 +11,6 @@ namespace Microsoft.OpenApi.Interfaces /// internal interface IOpenApiVersionService { - /// - /// Parse the string to a object. - /// - /// The reference string. - /// The type of the reference. - /// The summary of the reference. - /// A reference description - /// The object or null. - OpenApiReference ConvertToOpenApiReference(string reference, ReferenceType? type, string summary = null, string description = null); - /// /// Loads an OpenAPI Element from a document fragment /// @@ -28,7 +18,7 @@ internal interface IOpenApiVersionService /// document fragment node /// A host document instance. /// Instance of OpenAPIElement - T LoadElement(ParseNode node, OpenApiDocument doc) where T : IOpenApiElement; + T? LoadElement(ParseNode node, OpenApiDocument doc) where T : IOpenApiElement; /// /// Converts a generic RootNode instance into a strongly typed OpenApiDocument @@ -43,6 +33,6 @@ internal interface IOpenApiVersionService /// A YamlMappingNode. /// The scalar value we're parsing. /// The resulting node value. - string GetReferenceScalarValues(MapNode mapNode, string scalarValue); + string? GetReferenceScalarValues(MapNode mapNode, string scalarValue); } } diff --git a/src/Microsoft.OpenApi/Interfaces/IShallowCopyable.cs b/src/Microsoft.OpenApi/Interfaces/IShallowCopyable.cs index c1327bf0f..ecffde715 100644 --- a/src/Microsoft.OpenApi/Interfaces/IShallowCopyable.cs +++ b/src/Microsoft.OpenApi/Interfaces/IShallowCopyable.cs @@ -1,4 +1,4 @@ -namespace Microsoft.OpenApi.Interfaces; +namespace Microsoft.OpenApi.Interfaces; /// /// Interface for shallow copyable objects. /// diff --git a/src/Microsoft.OpenApi/JsonPointer.cs b/src/Microsoft.OpenApi/JsonPointer.cs index 110cca81e..627520c3b 100644 --- a/src/Microsoft.OpenApi/JsonPointer.cs +++ b/src/Microsoft.OpenApi/JsonPointer.cs @@ -39,7 +39,7 @@ private JsonPointer(string[] tokens) /// /// Gets the parent pointer. /// - public JsonPointer ParentPointer + public JsonPointer? ParentPointer { get { diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj index 5f0cb79cc..b3a511e88 100644 --- a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj +++ b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj @@ -10,6 +10,7 @@ true NU5048 + enable README.md diff --git a/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiDeprecationExtension.cs b/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiDeprecationExtension.cs index 6fa71600d..a61d93ce4 100644 --- a/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiDeprecationExtension.cs +++ b/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiDeprecationExtension.cs @@ -110,7 +110,7 @@ jsonNode is not JsonValue jsonValue || /// When the source element is not an object public static OpenApiDeprecationExtension Parse(JsonNode source) { - if (source is not JsonObject rawObject) return null; + if (source is not JsonObject rawObject) throw new ArgumentOutOfRangeException(nameof(source)); var extension = new OpenApiDeprecationExtension { RemovalDate = GetDateTimeOffsetValue(nameof(RemovalDate), rawObject), diff --git a/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiEnumValuesDescriptionExtension.cs b/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiEnumValuesDescriptionExtension.cs index 19b370518..f72479ba4 100644 --- a/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiEnumValuesDescriptionExtension.cs +++ b/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiEnumValuesDescriptionExtension.cs @@ -65,7 +65,7 @@ public void Write(IOpenApiWriter writer, OpenApiSpecVersion specVersion) /// When the source element is not an object public static OpenApiEnumValuesDescriptionExtension Parse(JsonNode source) { - if (source is not JsonObject rawObject) return null; + if (source is not JsonObject rawObject) throw new ArgumentOutOfRangeException(nameof(source)); var extension = new OpenApiEnumValuesDescriptionExtension(); if (rawObject.TryGetPropertyValue("values", out var values) && values is JsonArray valuesArray) { diff --git a/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiPagingExtension.cs b/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiPagingExtension.cs index 2e9a0c3f3..340d4ed23 100644 --- a/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiPagingExtension.cs +++ b/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiPagingExtension.cs @@ -73,7 +73,7 @@ public void Write(IOpenApiWriter writer, OpenApiSpecVersion specVersion) /// When the source element is not an object public static OpenApiPagingExtension Parse(JsonNode source) { - if (source is not JsonObject rawObject) return null; + if (source is not JsonObject rawObject) throw new ArgumentOutOfRangeException(nameof(source)); var extension = new OpenApiPagingExtension(); if (rawObject.TryGetPropertyValue(nameof(NextLinkName).ToFirstCharacterLowerCase(), out var nextLinkName) && nextLinkName is JsonValue nextLinkNameValue && nextLinkNameValue.TryGetValue(out var nextLinkNameStr)) { diff --git a/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiPrimaryErrorMessageExtension.cs b/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiPrimaryErrorMessageExtension.cs index a9e2f055a..aabcf0d26 100644 --- a/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiPrimaryErrorMessageExtension.cs +++ b/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiPrimaryErrorMessageExtension.cs @@ -40,7 +40,7 @@ public void Write(IOpenApiWriter writer, OpenApiSpecVersion specVersion) /// The . public static OpenApiPrimaryErrorMessageExtension Parse(JsonNode source) { - if (source is not JsonValue rawObject) return null; + if (source is not JsonValue rawObject) throw new ArgumentOutOfRangeException(nameof(source)); return new() { IsPrimaryErrorMessage = rawObject.TryGetValue(out var value) && value diff --git a/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiReservedParameterExtension.cs b/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiReservedParameterExtension.cs index 612e4cb74..eb58c1e5c 100644 --- a/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiReservedParameterExtension.cs +++ b/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiReservedParameterExtension.cs @@ -42,7 +42,7 @@ public bool? IsReserved /// public static OpenApiReservedParameterExtension Parse(JsonNode source) { - if (source is not JsonValue rawBoolean) return null; + if (source is not JsonValue rawBoolean) throw new ArgumentOutOfRangeException(nameof(source)); return new() { IsReserved = rawBoolean.TryGetValue(out var value) && value diff --git a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiCallback.cs b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiCallback.cs index 025abca20..1b18d237b 100644 --- a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiCallback.cs +++ b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiCallback.cs @@ -1,4 +1,4 @@ - + using System.Collections.Generic; using Microsoft.OpenApi.Expressions; using Microsoft.OpenApi.Interfaces; @@ -14,5 +14,5 @@ public interface IOpenApiCallback : IOpenApiReadOnlyExtensible, IShallowCopyable /// /// A Path Item Object used to define a callback request and expected responses. /// - public Dictionary PathItems { get; } + public Dictionary? PathItems { get; } } diff --git a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiDescribedElement.cs b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiDescribedElement.cs index 3deee3d3c..e41e7d6a6 100644 --- a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiDescribedElement.cs +++ b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiDescribedElement.cs @@ -1,4 +1,4 @@ -using Microsoft.OpenApi.Interfaces; +using Microsoft.OpenApi.Interfaces; namespace Microsoft.OpenApi.Models.Interfaces; @@ -11,7 +11,7 @@ public interface IOpenApiDescribedElement : IOpenApiElement /// Long description for the example. /// CommonMark syntax MAY be used for rich text representation. /// - public string Description { get; set; } + public string? Description { get; set; } } /// @@ -23,5 +23,5 @@ public interface IOpenApiReadOnlyDescribedElement : IOpenApiElement /// Long description for the example. /// CommonMark syntax MAY be used for rich text representation. /// - public string Description { get; } + public string? Description { get; } } diff --git a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiExample.cs b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiExample.cs index 9a14aca95..b572e8e6f 100644 --- a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiExample.cs +++ b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiExample.cs @@ -1,4 +1,4 @@ -using System.Text.Json.Nodes; +using System.Text.Json.Nodes; using Microsoft.OpenApi.Interfaces; namespace Microsoft.OpenApi.Models.Interfaces; @@ -14,7 +14,7 @@ public interface IOpenApiExample : IOpenApiDescribedElement, IOpenApiSummarizedE /// exclusive. To represent examples of media types that cannot naturally represented /// in JSON or YAML, use a string value to contain the example, escaping where necessary. /// - public JsonNode Value { get; } + public JsonNode? Value { get; } /// /// A URL that points to the literal example. @@ -22,5 +22,5 @@ public interface IOpenApiExample : IOpenApiDescribedElement, IOpenApiSummarizedE /// included in JSON or YAML documents. /// The value field and externalValue field are mutually exclusive. /// - public string ExternalValue { get; } + public string? ExternalValue { get; } } diff --git a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiHeader.cs b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiHeader.cs index 69d7ec614..c6550caa6 100644 --- a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiHeader.cs +++ b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiHeader.cs @@ -1,4 +1,4 @@ - + using System.Collections.Generic; using System.Text.Json.Nodes; using Microsoft.OpenApi.Interfaces; @@ -45,21 +45,21 @@ public interface IOpenApiHeader : IOpenApiDescribedElement, IOpenApiReadOnlyExte /// /// The schema defining the type used for the request body. /// - public IOpenApiSchema Schema { get; } + public IOpenApiSchema? Schema { get; } /// /// Example of the media type. /// - public JsonNode Example { get; } + public JsonNode? Example { get; } /// /// Examples of the media type. /// - public IDictionary Examples { get; } + public IDictionary? Examples { get; } /// /// A map containing the representations for the header. /// - public IDictionary Content { get; } + public IDictionary? Content { get; } } diff --git a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiLink.cs b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiLink.cs index f6ee7b49d..6fc9abeb6 100644 --- a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiLink.cs +++ b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiLink.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using Microsoft.OpenApi.Interfaces; namespace Microsoft.OpenApi.Models.Interfaces; @@ -13,25 +13,25 @@ public interface IOpenApiLink : IOpenApiDescribedElement, IOpenApiReadOnlyExtens /// A relative or absolute reference to an OAS operation. /// This field is mutually exclusive of the operationId field, and MUST point to an Operation Object. /// - public string OperationRef { get; } + public string? OperationRef { get; } /// /// The name of an existing, resolvable OAS operation, as defined with a unique operationId. /// This field is mutually exclusive of the operationRef field. /// - public string OperationId { get; } + public string? OperationId { get; } /// /// A map representing parameters to pass to an operation as specified with operationId or identified via operationRef. /// - public IDictionary Parameters { get; } + public IDictionary? Parameters { get; } /// /// A literal value or {expression} to use as a request body when calling the target operation. /// - public RuntimeExpressionAnyWrapper RequestBody { get; } + public RuntimeExpressionAnyWrapper? RequestBody { get; } /// /// A server object to be used by the target operation. /// - public OpenApiServer Server { get; } + public OpenApiServer? Server { get; } } diff --git a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiParameter.cs b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiParameter.cs index a55ce742b..63c3a860f 100644 --- a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiParameter.cs +++ b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiParameter.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Text.Json.Nodes; using Microsoft.OpenApi.Interfaces; @@ -16,7 +16,7 @@ public interface IOpenApiParameter : IOpenApiDescribedElement, IOpenApiReadOnlyE /// If in is "header" and the name field is "Accept", "Content-Type" or "Authorization", the parameter definition SHALL be ignored. /// For all other cases, the name corresponds to the parameter name used by the in property. /// - public string Name { get; } + public string? Name { get; } /// /// REQUIRED. The location of the parameter. @@ -72,7 +72,7 @@ public interface IOpenApiParameter : IOpenApiDescribedElement, IOpenApiReadOnlyE /// /// The schema defining the type used for the parameter. /// - public IOpenApiSchema Schema { get; } + public IOpenApiSchema? Schema { get; } /// /// Examples of the media type. Each example SHOULD contain a value @@ -81,7 +81,7 @@ public interface IOpenApiParameter : IOpenApiDescribedElement, IOpenApiReadOnlyE /// Furthermore, if referencing a schema which contains an example, /// the examples value SHALL override the example provided by the schema. /// - public IDictionary Examples { get; } + public IDictionary? Examples { get; } /// /// Example of the media type. The example SHOULD match the specified schema and encoding properties @@ -91,7 +91,7 @@ public interface IOpenApiParameter : IOpenApiDescribedElement, IOpenApiReadOnlyE /// To represent examples of media types that cannot naturally be represented in JSON or YAML, /// a string value can contain the example with escaping where necessary. /// - public JsonNode Example { get; } + public JsonNode? Example { get; } /// /// A map containing the representations for the parameter. @@ -102,5 +102,5 @@ public interface IOpenApiParameter : IOpenApiDescribedElement, IOpenApiReadOnlyE /// When example or examples are provided in conjunction with the schema object, /// the example MUST follow the prescribed serialization strategy for the parameter. /// - public IDictionary Content { get; } + public IDictionary? Content { get; } } diff --git a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiPathItem.cs b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiPathItem.cs index d69f06473..f4348154e 100644 --- a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiPathItem.cs +++ b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiPathItem.cs @@ -14,16 +14,16 @@ public interface IOpenApiPathItem : IOpenApiDescribedElement, IOpenApiSummarized /// /// Gets the definition of operations on this path. /// - public IDictionary Operations { get; } + public IDictionary? Operations { get; } /// /// An alternative server array to service all operations in this path. /// - public IList Servers { get; } + public IList? Servers { get; } /// /// A list of parameters that are applicable for all the operations described under this path. /// These parameters can be overridden at the operation level, but cannot be removed there. /// - public IList Parameters { get; } + public IList? Parameters { get; } } diff --git a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiRequestBody.cs b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiRequestBody.cs index b03bac603..b9c8304df 100644 --- a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiRequestBody.cs +++ b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiRequestBody.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Writers; @@ -19,17 +19,17 @@ public interface IOpenApiRequestBody : IOpenApiDescribedElement, IOpenApiReadOnl /// REQUIRED. The content of the request body. The key is a media type or media type range and the value describes it. /// For requests that match multiple keys, only the most specific key is applicable. e.g. text/plain overrides text/* /// - public IDictionary Content { get; } + public IDictionary? Content { get; } /// /// Converts the request body to a body parameter in preparation for a v2 serialization. /// /// The writer to use to read settings from. /// The converted OpenAPI parameter - IOpenApiParameter ConvertToBodyParameter(IOpenApiWriter writer); + IOpenApiParameter? ConvertToBodyParameter(IOpenApiWriter writer); /// /// Converts the request body to a set of form data parameters in preparation for a v2 serialization. /// /// The writer to use to read settings from /// The converted OpenAPI parameters - IEnumerable ConvertToFormDataParameters(IOpenApiWriter writer); + IEnumerable? ConvertToFormDataParameters(IOpenApiWriter writer); } diff --git a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiResponse.cs b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiResponse.cs index ee4e6df10..379526e0a 100644 --- a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiResponse.cs +++ b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiResponse.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using Microsoft.OpenApi.Interfaces; namespace Microsoft.OpenApi.Models.Interfaces; @@ -12,18 +12,18 @@ public interface IOpenApiResponse : IOpenApiDescribedElement, IOpenApiReadOnlyEx /// /// Maps a header name to its definition. /// - public IDictionary Headers { get; } + public IDictionary? Headers { get; } /// /// A map containing descriptions of potential response payloads. /// The key is a media type or media type range and the value describes it. /// - public IDictionary Content { get; } + public IDictionary? Content { get; } /// /// A map of operations links that can be followed from the response. /// The key of the map is a short name for the link, /// following the naming constraints of the names for Component Objects. /// - public IDictionary Links { get; } + public IDictionary? Links { get; } } diff --git a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiSchema.cs b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiSchema.cs index b6352311c..bd551a786 100644 --- a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiSchema.cs +++ b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiSchema.cs @@ -15,43 +15,43 @@ public interface IOpenApiSchema : IOpenApiDescribedElement, IOpenApiReadOnlyExte /// /// Follow JSON Schema definition. Short text providing information about the data. /// - public string Title { get; } + public string? Title { get; } /// /// $schema, a JSON Schema dialect identifier. Value must be a URI /// - public Uri Schema { get; } + public Uri? Schema { get; } /// /// $id - Identifies a schema resource with its canonical URI. /// - public string Id { get; } + public string? Id { get; } /// /// $comment - reserves a location for comments from schema authors to readers or maintainers of the schema. /// - public string Comment { get; } + public string? Comment { get; } /// /// $vocabulary- used in meta-schemas to identify the vocabularies available for use in schemas described by that meta-schema. /// - public IDictionary Vocabulary { get; } + public IDictionary? Vocabulary { get; } /// /// $dynamicRef - an applicator that allows for deferring the full resolution until runtime, at which point it is resolved each time it is encountered while evaluating an instance /// - public string DynamicRef { get; } + public string? DynamicRef { get; } /// /// $dynamicAnchor - used to create plain name fragments that are not tied to any particular structural location for referencing purposes, which are taken into consideration for dynamic referencing. /// - public string DynamicAnchor { get; } + public string? DynamicAnchor { get; } /// /// $defs - reserves a location for schema authors to inline re-usable JSON Schemas into a more general schema. /// The keyword does not directly affect the validation result /// - public IDictionary Definitions { get; } + public IDictionary? Definitions { get; } /// /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 @@ -77,14 +77,14 @@ public interface IOpenApiSchema : IOpenApiDescribedElement, IOpenApiReadOnlyExte /// /// Follow JSON Schema definition: https://json-schema.org/draft/2020-12/json-schema-validation /// - public string Const { get; } + public string? Const { get; } /// /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 /// While relying on JSON Schema's defined formats, /// the OAS offers a few additional predefined formats. /// - public string Format { get; } + public string? Format { get; } /// /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 @@ -110,7 +110,7 @@ public interface IOpenApiSchema : IOpenApiDescribedElement, IOpenApiReadOnlyExte /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 /// This string SHOULD be a valid regular expression, according to the ECMA 262 regular expression dialect /// - public string Pattern { get; } + public string? Pattern { get; } /// /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 @@ -123,7 +123,7 @@ public interface IOpenApiSchema : IOpenApiDescribedElement, IOpenApiReadOnlyExte /// Unlike JSON Schema, the value MUST conform to the defined type for the Schema Object defined at the same level. /// For example, if type is string, then default can be "foo" but cannot be 1. /// - public JsonNode Default { get; } + public JsonNode? Default { get; } /// /// Relevant only for Schema "properties" definitions. Declares the property as "read only". @@ -149,37 +149,37 @@ public interface IOpenApiSchema : IOpenApiDescribedElement, IOpenApiReadOnlyExte /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 /// Inline or referenced schema MUST be of a Schema Object and not a standard JSON Schema. /// - public IList AllOf { get; } + public IList? AllOf { get; } /// /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 /// Inline or referenced schema MUST be of a Schema Object and not a standard JSON Schema. /// - public IList OneOf { get; } + public IList? OneOf { get; } /// /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 /// Inline or referenced schema MUST be of a Schema Object and not a standard JSON Schema. /// - public IList AnyOf { get; } + public IList? AnyOf { get; } /// /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 /// Inline or referenced schema MUST be of a Schema Object and not a standard JSON Schema. /// - public IOpenApiSchema Not { get; } + public IOpenApiSchema? Not { get; } /// /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 /// - public ISet Required { get; } + public ISet? Required { get; } /// /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 /// Value MUST be an object and not an array. Inline or referenced schema MUST be of a Schema Object /// and not a standard JSON Schema. items MUST be present if the type is array. /// - public IOpenApiSchema Items { get; } + public IOpenApiSchema? Items { get; } /// /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 @@ -200,7 +200,7 @@ public interface IOpenApiSchema : IOpenApiDescribedElement, IOpenApiReadOnlyExte /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 /// Property definitions MUST be a Schema Object and not a standard JSON Schema (inline or referenced). /// - public IDictionary Properties { get; } + public IDictionary? Properties { get; } /// /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 @@ -209,7 +209,7 @@ public interface IOpenApiSchema : IOpenApiDescribedElement, IOpenApiReadOnlyExte /// egular expression dialect. Each property value of this object MUST be an object, and each object MUST /// be a valid Schema Object not a standard JSON Schema. /// - public IDictionary PatternProperties { get; } + public IDictionary? PatternProperties { get; } /// /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 @@ -231,32 +231,32 @@ public interface IOpenApiSchema : IOpenApiDescribedElement, IOpenApiReadOnlyExte /// Value can be boolean or object. Inline or referenced schema /// MUST be of a Schema Object and not a standard JSON Schema. /// - public IOpenApiSchema AdditionalProperties { get; } + public IOpenApiSchema? AdditionalProperties { get; } /// /// Adds support for polymorphism. The discriminator is an object name that is used to differentiate /// between other schemas which may satisfy the payload description. /// - public OpenApiDiscriminator Discriminator { get; } + public OpenApiDiscriminator? Discriminator { get; } /// /// A free-form property to include an example of an instance for this schema. /// To represent examples that cannot be naturally represented in JSON or YAML, /// a string value can be used to contain the example with escaping where necessary. /// - public JsonNode Example { get; } + public JsonNode? Example { get; } /// /// A free-form property to include examples of an instance for this schema. /// To represent examples that cannot be naturally represented in JSON or YAML, /// a list of values can be used to contain the examples with escaping where necessary. /// - public IList Examples { get; } + public IList? Examples { get; } /// /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 /// - public IList Enum { get; } + public IList? Enum { get; } /// /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 @@ -266,7 +266,7 @@ public interface IOpenApiSchema : IOpenApiDescribedElement, IOpenApiReadOnlyExte /// /// Additional external documentation for this schema. /// - public OpenApiExternalDocs ExternalDocs { get; } + public OpenApiExternalDocs? ExternalDocs { get; } /// /// Specifies that a schema is deprecated and SHOULD be transitioned out of usage. @@ -278,21 +278,21 @@ public interface IOpenApiSchema : IOpenApiDescribedElement, IOpenApiReadOnlyExte /// This MAY be used only on properties schemas. It has no effect on root schemas. /// Adds additional metadata to describe the XML representation of this property. /// - public OpenApiXml Xml { get; } + public OpenApiXml? Xml { get; } /// /// This object stores any unrecognized keywords found in the schema. /// - public IDictionary UnrecognizedKeywords { get; } + public IDictionary? UnrecognizedKeywords { get; } /// /// Any annotation to attach to the schema to be used by the application. /// Annotations are NOT (de)serialized with the schema and can be used for custom properties. /// - public IDictionary Annotations { get; } + public IDictionary? Annotations { get; } /// /// Follow JSON Schema definition:https://json-schema.org/draft/2020-12/json-schema-validation#section-6.5.4 /// - public IDictionary> DependentRequired { get; } + public IDictionary>? DependentRequired { get; } } diff --git a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiSecurityScheme.cs b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiSecurityScheme.cs index d076a6896..202337feb 100644 --- a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiSecurityScheme.cs +++ b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiSecurityScheme.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using Microsoft.OpenApi.Interfaces; @@ -18,7 +18,7 @@ public interface IOpenApiSecurityScheme : IOpenApiDescribedElement, IOpenApiRead /// /// REQUIRED. The name of the header, query or cookie parameter to be used. /// - public string Name { get; } + public string? Name { get; } /// /// REQUIRED. The location of the API key. Valid values are "query", "header" or "cookie". @@ -29,22 +29,22 @@ public interface IOpenApiSecurityScheme : IOpenApiDescribedElement, IOpenApiRead /// REQUIRED. The name of the HTTP Authorization scheme to be used /// in the Authorization header as defined in RFC7235. /// - public string Scheme { get; } + public string? Scheme { get; } /// /// A hint to the client to identify how the bearer token is formatted. /// Bearer tokens are usually generated by an authorization server, /// so this information is primarily for documentation purposes. /// - public string BearerFormat { get; } + public string? BearerFormat { get; } /// /// REQUIRED. An object containing configuration information for the flow types supported. /// - public OpenApiOAuthFlows Flows { get; } + public OpenApiOAuthFlows? Flows { get; } /// /// REQUIRED. OpenId Connect URL to discover OAuth2 configuration values. /// - public Uri OpenIdConnectUrl { get; } + public Uri? OpenIdConnectUrl { get; } } diff --git a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiSummarizedElement.cs b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiSummarizedElement.cs index 3273b03f5..e3595bf69 100644 --- a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiSummarizedElement.cs +++ b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiSummarizedElement.cs @@ -1,4 +1,4 @@ -using Microsoft.OpenApi.Interfaces; +using Microsoft.OpenApi.Interfaces; namespace Microsoft.OpenApi.Models.Interfaces; /// @@ -9,5 +9,5 @@ public interface IOpenApiSummarizedElement : IOpenApiElement /// /// Short description for the example. /// - public string Summary { get; set; } + public string? Summary { get; set; } } diff --git a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiTag.cs b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiTag.cs index fdf022413..00a45f4d9 100644 --- a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiTag.cs +++ b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiTag.cs @@ -1,4 +1,4 @@ -using Microsoft.OpenApi.Interfaces; +using Microsoft.OpenApi.Interfaces; namespace Microsoft.OpenApi.Models.Interfaces; @@ -11,10 +11,10 @@ public interface IOpenApiTag : IOpenApiReadOnlyExtensible, IOpenApiReadOnlyDescr /// /// The name of the tag. /// - public string Name { get; } + public string? Name { get; } /// /// Additional external documentation for this tag. /// - public OpenApiExternalDocs ExternalDocs { get; } + public OpenApiExternalDocs? ExternalDocs { get; } } diff --git a/src/Microsoft.OpenApi/Models/OpenApiCallback.cs b/src/Microsoft.OpenApi/Models/OpenApiCallback.cs index 96f5c5cf4..435d9155e 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiCallback.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiCallback.cs @@ -16,14 +16,14 @@ namespace Microsoft.OpenApi.Models public class OpenApiCallback : IOpenApiReferenceable, IOpenApiExtensible, IOpenApiCallback { /// - public Dictionary PathItems { get; set; } + public Dictionary? PathItems { get; set; } = []; /// /// This object MAY be extended with Specification Extensions. /// - public IDictionary Extensions { get; set; } = new Dictionary(); + public IDictionary? Extensions { get; set; } = new Dictionary(); /// /// Parameter-less constructor @@ -36,7 +36,7 @@ public OpenApiCallback() { } internal OpenApiCallback(IOpenApiCallback callback) { Utils.CheckArgumentNull(callback); - PathItems = callback?.PathItems != null ? new(callback?.PathItems) : null; + PathItems = callback?.PathItems != null ? new(callback.PathItems) : null; Extensions = callback?.Extensions != null ? new Dictionary(callback.Extensions) : null; } @@ -81,9 +81,12 @@ internal void SerializeInternal(IOpenApiWriter writer, OpenApiSpecVersion versio writer.WriteStartObject(); // path items - foreach (var item in PathItems) + if (PathItems != null) { - writer.WriteRequiredObject(item.Key.Expression, item.Value, callback); + foreach (var item in PathItems) + { + writer.WriteRequiredObject(item.Key.Expression, item.Value, callback); + } } // extensions diff --git a/src/Microsoft.OpenApi/Models/OpenApiContact.cs b/src/Microsoft.OpenApi/Models/OpenApiContact.cs index 15d67cc76..940388887 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiContact.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiContact.cs @@ -16,23 +16,23 @@ public class OpenApiContact : IOpenApiSerializable, IOpenApiExtensible /// /// The identifying name of the contact person/organization. /// - public string Name { get; set; } + public string? Name { get; set; } /// /// The URL pointing to the contact information. MUST be in the format of a URL. /// - public Uri Url { get; set; } + public Uri? Url { get; set; } /// /// The email address of the contact person/organization. /// MUST be in the format of an email address. /// - public string Email { get; set; } + public string? Email { get; set; } /// /// This object MAY be extended with Specification Extensions. /// - public IDictionary Extensions { get; set; } = new Dictionary(); + public IDictionary? Extensions { get; set; } = new Dictionary(); /// /// Parameter-less constructor diff --git a/src/Microsoft.OpenApi/Models/OpenApiDiscriminator.cs b/src/Microsoft.OpenApi/Models/OpenApiDiscriminator.cs index 342025f9f..3bbae4561 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiDiscriminator.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiDiscriminator.cs @@ -15,17 +15,17 @@ public class OpenApiDiscriminator : IOpenApiSerializable, IOpenApiExtensible /// /// REQUIRED. The name of the property in the payload that will hold the discriminator value. /// - public string PropertyName { get; set; } + public string? PropertyName { get; set; } /// /// An object to hold mappings between payload values and schema names or references. /// - public IDictionary Mapping { get; set; } = new Dictionary(); + public IDictionary? Mapping { get; set; } = new Dictionary(); /// /// This object MAY be extended with Specification Extensions. /// - public IDictionary Extensions { get; set; } = new Dictionary(); + public IDictionary? Extensions { get; set; } = new Dictionary(); /// /// Parameter-less constructor diff --git a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs index 3354a6717..0f69409d6 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs @@ -132,16 +132,16 @@ public OpenApiDocument() /// public OpenApiDocument(OpenApiDocument? document) { - Workspace = document?.Workspace != null ? new(document?.Workspace) : null; - Info = document?.Info != null ? new(document?.Info) : new OpenApiInfo(); + Workspace = document?.Workspace != null ? new(document.Workspace) : null; + Info = document?.Info != null ? new(document.Info) : new OpenApiInfo(); JsonSchemaDialect = document?.JsonSchemaDialect ?? JsonSchemaDialect; Servers = document?.Servers != null ? new List(document.Servers) : null; - Paths = document?.Paths != null ? new(document?.Paths) : new OpenApiPaths(); + Paths = document?.Paths != null ? new(document.Paths) : new OpenApiPaths(); Webhooks = document?.Webhooks != null ? new Dictionary(document.Webhooks) : null; Components = document?.Components != null ? new(document?.Components) : null; Security = document?.Security != null ? new List(document.Security) : null; Tags = document?.Tags != null ? new HashSet(document.Tags, OpenApiTagComparer.Instance) : null; - ExternalDocs = document?.ExternalDocs != null ? new(document?.ExternalDocs) : null; + ExternalDocs = document?.ExternalDocs != null ? new(document.ExternalDocs) : null; Extensions = document?.Extensions != null ? new Dictionary(document.Extensions) : null; Metadata = document?.Metadata != null ? new Dictionary(document.Metadata) : null; BaseUri = document?.BaseUri != null ? document.BaseUri : new(OpenApiConstants.BaseRegistryUri + Guid.NewGuid()); @@ -294,12 +294,19 @@ public void SerializeAsV2(IOpenApiWriter writer) if (loops.TryGetValue(typeof(IOpenApiSchema), out var schemas)) { - var openApiSchemas = schemas.Cast().Distinct().OfType() - .ToDictionary(k => k.Reference.Id, v => v); + var openApiSchemas = schemas.Cast() + .Distinct() + .OfType() + .Where(k => k.Reference?.Id is not null) + .ToDictionary( + k => k.Reference?.Id!, + v => v + ); + foreach (var schema in openApiSchemas.Values.ToList()) { - FindSchemaReferences.ResolveSchemas(Components, openApiSchemas); + FindSchemaReferences.ResolveSchemas(Components, openApiSchemas!); } writer.WriteOptionalMap( @@ -337,7 +344,9 @@ public void SerializeAsV2(IOpenApiWriter writer) { foreach (var requestBody in Components.RequestBodies.Where(b => !parameters.ContainsKey(b.Key))) { - parameters.Add(requestBody.Key, requestBody.Value.ConvertToBodyParameter(writer)); + var paramValue = requestBody.Value.ConvertToBodyParameter(writer); + if (paramValue is not null) + parameters.Add(requestBody.Key, paramValue); } } writer.WriteOptionalMap( @@ -406,7 +415,7 @@ public void SerializeAsV2(IOpenApiWriter writer) } } - private static string ParseServerUrl(OpenApiServer server) + private static string? ParseServerUrl(OpenApiServer server) { return server.ReplaceServerUrlVariables(new Dictionary(0)); } @@ -422,61 +431,70 @@ private static void WriteHostInfoV2(IOpenApiWriter writer, IList? // one host, port, and base path. var serverUrl = ParseServerUrl(servers[0]); - // Divide the URL in the Url property into host and basePath required in OpenAPI V2 - // The Url property cannot contain path templating to be valid for V2 serialization. - var firstServerUrl = new Uri(serverUrl, UriKind.RelativeOrAbsolute); - - // host - if (firstServerUrl.IsAbsoluteUri) + if (serverUrl != null) { - writer.WriteProperty( - OpenApiConstants.Host, - firstServerUrl.GetComponents(UriComponents.Host | UriComponents.Port, UriFormat.SafeUnescaped)); + // Divide the URL in the Url property into host and basePath required in OpenAPI V2 + // The Url property cannot contain path templating to be valid for V2 serialization. + var firstServerUrl = new Uri(serverUrl, UriKind.RelativeOrAbsolute); - // basePath - if (firstServerUrl.AbsolutePath != "/") - { - writer.WriteProperty(OpenApiConstants.BasePath, firstServerUrl.AbsolutePath); - } - } - else - { - var relativeUrl = firstServerUrl.OriginalString; - if (relativeUrl.StartsWith("//", StringComparison.OrdinalIgnoreCase)) + // host + if (firstServerUrl.IsAbsoluteUri) { - var pathPosition = relativeUrl.IndexOf('/', 3); - writer.WriteProperty(OpenApiConstants.Host, relativeUrl.Substring(0, pathPosition)); - relativeUrl = relativeUrl.Substring(pathPosition); + writer.WriteProperty( + OpenApiConstants.Host, + firstServerUrl.GetComponents(UriComponents.Host | UriComponents.Port, UriFormat.SafeUnescaped)); + + // basePath + if (firstServerUrl.AbsolutePath != "/") + { + writer.WriteProperty(OpenApiConstants.BasePath, firstServerUrl.AbsolutePath); + } } - if (!String.IsNullOrEmpty(relativeUrl) && relativeUrl != "/") + else { - writer.WriteProperty(OpenApiConstants.BasePath, relativeUrl); + var relativeUrl = firstServerUrl.OriginalString; + if (relativeUrl.StartsWith("//", StringComparison.OrdinalIgnoreCase)) + { + var pathPosition = relativeUrl.IndexOf('/', 3); + writer.WriteProperty(OpenApiConstants.Host, relativeUrl.Substring(0, pathPosition)); + relativeUrl = relativeUrl.Substring(pathPosition); + } + if (!String.IsNullOrEmpty(relativeUrl) && relativeUrl != "/") + { + writer.WriteProperty(OpenApiConstants.BasePath, relativeUrl); + } } - } - // Consider all schemes of the URLs in the server list that have the same - // host, port, and base path as the first server. - var schemes = servers.Select( - s => + // Consider all schemes of the URLs in the server list that have the same + // host, port, and base path as the first server. + var schemes = servers.Select( + s => + { + Uri.TryCreate(ParseServerUrl(s), UriKind.RelativeOrAbsolute, out var url); + return url; + }) + .Where( + u => u is not null && + Uri.Compare( + u, + firstServerUrl, + UriComponents.Host | UriComponents.Port | UriComponents.Path, + UriFormat.SafeUnescaped, + StringComparison.OrdinalIgnoreCase) == + 0 && u.IsAbsoluteUri) + .Select(u => u!.Scheme) + .Distinct() + .ToList(); + + // schemes + writer.WriteOptionalCollection(OpenApiConstants.Schemes, schemes, (w, s) => + { + if(!string.IsNullOrEmpty(s) && s is not null) { - Uri.TryCreate(ParseServerUrl(s), UriKind.RelativeOrAbsolute, out var url); - return url; - }) - .Where( - u => u is not null && - Uri.Compare( - u, - firstServerUrl, - UriComponents.Host | UriComponents.Port | UriComponents.Path, - UriFormat.SafeUnescaped, - StringComparison.OrdinalIgnoreCase) == - 0 && u.IsAbsoluteUri) - .Select(u => u!.Scheme) - .Distinct() - .ToList(); - - // schemes - writer.WriteOptionalCollection(OpenApiConstants.Schemes, schemes, (w, s) => w.WriteValue(s)); + w.WriteValue(s); + } + }); + } } /// @@ -548,19 +566,15 @@ private static string ConvertByteArrayToString(byte[] hash) return null; } - if (!reference.Type.HasValue) - { - throw new ArgumentException(Properties.SRResource.LocalReferenceRequiresType); - } - string uriLocation; - if (reference.Id.Contains("/")) // this means its a URL reference + var id = reference.Id; + if (!string.IsNullOrEmpty(id) && id!.Contains("/")) // this means its a URL reference { - uriLocation = reference.Id; + uriLocation = id; } else { - string relativePath = OpenApiConstants.ComponentsSegment + reference.Type.GetDisplayName() + "/" + reference.Id; + string relativePath = OpenApiConstants.ComponentsSegment + reference.Type.GetDisplayName() + "/" + id; uriLocation = useExternal ? Workspace?.GetDocumentId(reference.ExternalResource)?.OriginalString + relativePath @@ -704,9 +718,10 @@ public override void Visit(IOpenApiReferenceHolder referenceHolder) switch (referenceHolder) { case OpenApiSchemaReference schema: - if (!Schemas.ContainsKey(schema.Reference.Id)) + var id = schema.Reference?.Id; + if (id is not null && Schemas is not null && !Schemas.ContainsKey(id)) { - Schemas.Add(schema.Reference.Id, schema); + Schemas.Add(id, schema); } break; @@ -719,10 +734,14 @@ public override void Visit(IOpenApiReferenceHolder referenceHolder) public override void Visit(IOpenApiSchema schema) { // This is needed to handle schemas used in Responses in components - if (schema is OpenApiSchemaReference {Reference: not null} schemaReference && !Schemas.ContainsKey(schemaReference.Reference.Id)) + if (schema is OpenApiSchemaReference { Reference: not null } schemaReference) { - Schemas.Add(schemaReference.Reference.Id, schema); - } + var id = schemaReference.Reference?.Id; + if (id is not null && Schemas is not null && !Schemas.ContainsKey(id)) + { + Schemas.Add(id, schema); + } + } base.Visit(schema); } } diff --git a/src/Microsoft.OpenApi/Models/OpenApiEncoding.cs b/src/Microsoft.OpenApi/Models/OpenApiEncoding.cs index bb8bfab17..4eae8e6ce 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiEncoding.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiEncoding.cs @@ -20,12 +20,12 @@ public class OpenApiEncoding : IOpenApiSerializable, IOpenApiExtensible /// The value can be a specific media type (e.g. application/json), /// a wildcard media type (e.g. image/*), or a comma-separated list of the two types. /// - public string ContentType { get; set; } + public string? ContentType { get; set; } /// /// A map allowing additional information to be provided as headers. /// - public IDictionary Headers { get; set; } = new Dictionary(); + public IDictionary? Headers { get; set; } = new Dictionary(); /// /// Describes how a specific property value will be serialized depending on its type. @@ -52,7 +52,7 @@ public class OpenApiEncoding : IOpenApiSerializable, IOpenApiExtensible /// /// This object MAY be extended with Specification Extensions. /// - public IDictionary Extensions { get; set; } = new Dictionary(); + public IDictionary? Extensions { get; set; } = new Dictionary(); /// /// Parameter-less constructor diff --git a/src/Microsoft.OpenApi/Models/OpenApiError.cs b/src/Microsoft.OpenApi/Models/OpenApiError.cs index 54b98a067..8a42cb38a 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiError.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiError.cs @@ -20,7 +20,7 @@ public OpenApiError(OpenApiException exception) : this(exception.Pointer, except /// /// Initializes the class. /// - public OpenApiError(string pointer, string message) + public OpenApiError(string? pointer, string message) { Pointer = pointer; Message = message; @@ -43,7 +43,7 @@ public OpenApiError(OpenApiError error) /// /// Pointer to the location of the error. /// - public string Pointer { get; set; } + public string? Pointer { get; set; } /// /// Gets the string representation of . diff --git a/src/Microsoft.OpenApi/Models/OpenApiExample.cs b/src/Microsoft.OpenApi/Models/OpenApiExample.cs index bdfd42f4e..1470ca51a 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiExample.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiExample.cs @@ -16,19 +16,19 @@ namespace Microsoft.OpenApi.Models public class OpenApiExample : IOpenApiReferenceable, IOpenApiExtensible, IOpenApiExample { /// - public string Summary { get; set; } + public string? Summary { get; set; } /// - public string Description { get; set; } + public string? Description { get; set; } /// - public string ExternalValue { get; set; } + public string? ExternalValue { get; set; } /// - public JsonNode Value { get; set; } + public JsonNode? Value { get; set; } /// - public IDictionary Extensions { get; set; } = new Dictionary(); + public IDictionary? Extensions { get; set; } = new Dictionary(); /// /// Parameter-less constructor diff --git a/src/Microsoft.OpenApi/Models/OpenApiExtensibleDictionary.cs b/src/Microsoft.OpenApi/Models/OpenApiExtensibleDictionary.cs index 86fe7ea73..e9b07bf58 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiExtensibleDictionary.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiExtensibleDictionary.cs @@ -20,7 +20,7 @@ public abstract class OpenApiExtensibleDictionary : Dictionary, /// /// Parameterless constructor /// - protected OpenApiExtensibleDictionary():this(null) { } + protected OpenApiExtensibleDictionary():this([]) { } /// /// Initializes a copy of class. /// @@ -28,7 +28,7 @@ protected OpenApiExtensibleDictionary():this(null) { } /// The dictionary of . protected OpenApiExtensibleDictionary( Dictionary dictionary, - IDictionary extensions = null) : base(dictionary is null ? [] : dictionary) + IDictionary? extensions = null) : base(dictionary is null ? [] : dictionary) { Extensions = extensions != null ? new Dictionary(extensions) : []; } @@ -36,7 +36,7 @@ protected OpenApiExtensibleDictionary( /// /// This object MAY be extended with Specification Extensions. /// - public IDictionary Extensions { get; set; } + public IDictionary? Extensions { get; set; } /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiExternalDocs.cs b/src/Microsoft.OpenApi/Models/OpenApiExternalDocs.cs index cceace01d..2694aa26a 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiExternalDocs.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiExternalDocs.cs @@ -16,17 +16,17 @@ public class OpenApiExternalDocs : IOpenApiSerializable, IOpenApiExtensible /// /// A short description of the target documentation. /// - public string Description { get; set; } + public string? Description { get; set; } /// /// REQUIRED. The URL for the target documentation. Value MUST be in the format of a URL. /// - public Uri Url { get; set; } + public Uri? Url { get; set; } /// /// This object MAY be extended with Specification Extensions. /// - public IDictionary Extensions { get; set; } = new Dictionary(); + public IDictionary? Extensions { get; set; } = new Dictionary(); /// /// Parameter-less constructor @@ -69,7 +69,7 @@ public void SerializeAsV2(IOpenApiWriter writer) private void WriteInternal(IOpenApiWriter writer, OpenApiSpecVersion specVersion) { - Utils.CheckArgumentNull(writer);; + Utils.CheckArgumentNull(writer); writer.WriteStartObject(); diff --git a/src/Microsoft.OpenApi/Models/OpenApiHeader.cs b/src/Microsoft.OpenApi/Models/OpenApiHeader.cs index 08dd04b99..82d17aece 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiHeader.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiHeader.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System; @@ -20,7 +20,7 @@ namespace Microsoft.OpenApi.Models public class OpenApiHeader : IOpenApiHeader, IOpenApiExtensible { /// - public string Description { get; set; } + public string? Description { get; set; } /// public bool Required { get; set; } @@ -41,19 +41,19 @@ public class OpenApiHeader : IOpenApiHeader, IOpenApiExtensible public bool AllowReserved { get; set; } /// - public IOpenApiSchema Schema { get; set; } + public IOpenApiSchema? Schema { get; set; } /// - public JsonNode Example { get; set; } + public JsonNode? Example { get; set; } /// - public IDictionary Examples { get; set; } = new Dictionary(); + public IDictionary? Examples { get; set; } = new Dictionary(); /// - public IDictionary Content { get; set; } = new Dictionary(); + public IDictionary? Content { get; set; } = new Dictionary(); /// - public IDictionary Extensions { get; set; } = new Dictionary(); + public IDictionary? Extensions { get; set; } = new Dictionary(); /// /// Parameter-less constructor @@ -73,7 +73,7 @@ internal OpenApiHeader(IOpenApiHeader header) Style = header.Style ?? Style; Explode = header.Explode; AllowReserved = header.AllowReserved; - Schema = header.Schema.CreateShallowCopy(); + Schema = header.Schema?.CreateShallowCopy(); Example = header.Example != null ? JsonNodeCloneHelper.Clone(header.Example) : null; Examples = header.Examples != null ? new Dictionary(header.Examples) : null; Content = header.Content != null ? new Dictionary(header.Content) : null; diff --git a/src/Microsoft.OpenApi/Models/OpenApiInfo.cs b/src/Microsoft.OpenApi/Models/OpenApiInfo.cs index 68e37ee20..93e89438c 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiInfo.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiInfo.cs @@ -16,42 +16,42 @@ public class OpenApiInfo : IOpenApiSerializable, IOpenApiExtensible /// /// REQUIRED. The title of the application. /// - public string Title { get; set; } + public string? Title { get; set; } /// /// A short summary of the API. /// - public string Summary { get; set; } + public string? Summary { get; set; } /// /// A short description of the application. /// - public string Description { get; set; } + public string? Description { get; set; } /// /// REQUIRED. The version of the OpenAPI document. /// - public string Version { get; set; } + public string? Version { get; set; } /// /// A URL to the Terms of Service for the API. MUST be in the format of a URL. /// - public Uri TermsOfService { get; set; } + public Uri? TermsOfService { get; set; } /// /// The contact information for the exposed API. /// - public OpenApiContact Contact { get; set; } + public OpenApiContact? Contact { get; set; } /// /// The license information for the exposed API. /// - public OpenApiLicense License { get; set; } + public OpenApiLicense? License { get; set; } /// /// This object MAY be extended with Specification Extensions. /// - public IDictionary Extensions { get; set; } = new Dictionary(); + public IDictionary? Extensions { get; set; } = new Dictionary(); /// /// Parameter-less constructor @@ -68,8 +68,8 @@ public OpenApiInfo(OpenApiInfo info) Description = info?.Description ?? Description; Version = info?.Version ?? Version; TermsOfService = info?.TermsOfService ?? TermsOfService; - Contact = info?.Contact != null ? new(info?.Contact) : null; - License = info?.License != null ? new(info?.License) : null; + Contact = info?.Contact != null ? new(info.Contact) : null; + License = info?.License != null ? new(info.License) : null; Extensions = info?.Extensions != null ? new Dictionary(info.Extensions) : null; } @@ -100,7 +100,7 @@ public void SerializeAsV3(IOpenApiWriter writer) /// private void SerializeInternal(IOpenApiWriter writer, OpenApiSpecVersion version, Action callback) { - Utils.CheckArgumentNull(writer);; + Utils.CheckArgumentNull(writer); writer.WriteStartObject(); // title @@ -130,7 +130,7 @@ private void SerializeInternal(IOpenApiWriter writer, OpenApiSpecVersion version /// public void SerializeAsV2(IOpenApiWriter writer) { - Utils.CheckArgumentNull(writer);; + Utils.CheckArgumentNull(writer); writer.WriteStartObject(); diff --git a/src/Microsoft.OpenApi/Models/OpenApiLicense.cs b/src/Microsoft.OpenApi/Models/OpenApiLicense.cs index 6a8d4bcf7..8aea264e6 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiLicense.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiLicense.cs @@ -16,22 +16,22 @@ public class OpenApiLicense : IOpenApiSerializable, IOpenApiExtensible /// /// REQUIRED. The license name used for the API. /// - public string Name { get; set; } + public string? Name { get; set; } /// /// An SPDX license expression for the API. The identifier field is mutually exclusive of the url field. /// - public string Identifier { get; set; } + public string? Identifier { get; set; } /// /// The URL pointing to the contact information. MUST be in the format of a URL. /// - public Uri Url { get; set; } + public Uri? Url { get; set; } /// /// This object MAY be extended with Specification Extensions. /// - public IDictionary Extensions { get; set; } = new Dictionary(); + public IDictionary? Extensions { get; set; } = new Dictionary(); /// /// Parameterless constructor @@ -79,7 +79,7 @@ public void SerializeAsV2(IOpenApiWriter writer) private void WriteInternal(IOpenApiWriter writer, OpenApiSpecVersion specVersion) { - Utils.CheckArgumentNull(writer);; + Utils.CheckArgumentNull(writer); writer.WriteStartObject(); // name diff --git a/src/Microsoft.OpenApi/Models/OpenApiLink.cs b/src/Microsoft.OpenApi/Models/OpenApiLink.cs index 09883b4a2..412577580 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiLink.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiLink.cs @@ -15,25 +15,25 @@ namespace Microsoft.OpenApi.Models public class OpenApiLink : IOpenApiReferenceable, IOpenApiExtensible, IOpenApiLink { /// - public string OperationRef { get; set; } + public string? OperationRef { get; set; } /// - public string OperationId { get; set; } + public string? OperationId { get; set; } /// - public IDictionary Parameters { get; set; } = new Dictionary(); + public IDictionary? Parameters { get; set; } = new Dictionary(); /// - public RuntimeExpressionAnyWrapper RequestBody { get; set; } + public RuntimeExpressionAnyWrapper? RequestBody { get; set; } /// - public string Description { get; set; } + public string? Description { get; set; } /// - public OpenApiServer Server { get; set; } + public OpenApiServer? Server { get; set; } /// - public IDictionary Extensions { get; set; } = new Dictionary(); + public IDictionary? Extensions { get; set; } = new Dictionary(); /// /// Parameterless constructor diff --git a/src/Microsoft.OpenApi/Models/OpenApiOAuthFlow.cs b/src/Microsoft.OpenApi/Models/OpenApiOAuthFlow.cs index 2385a4c55..d84417cef 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiOAuthFlow.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiOAuthFlow.cs @@ -17,28 +17,28 @@ public class OpenApiOAuthFlow : IOpenApiSerializable, IOpenApiExtensible /// REQUIRED. The authorization URL to be used for this flow. /// Applies to implicit and authorizationCode OAuthFlow. /// - public Uri AuthorizationUrl { get; set; } + public Uri? AuthorizationUrl { get; set; } /// /// REQUIRED. The token URL to be used for this flow. /// Applies to password, clientCredentials, and authorizationCode OAuthFlow. /// - public Uri TokenUrl { get; set; } + public Uri? TokenUrl { get; set; } /// /// The URL to be used for obtaining refresh tokens. /// - public Uri RefreshUrl { get; set; } + public Uri? RefreshUrl { get; set; } /// /// REQUIRED. A map between the scope name and a short description for it. /// - public IDictionary Scopes { get; set; } = new Dictionary(); + public IDictionary? Scopes { get; set; } = new Dictionary(); /// /// Specification Extensions. /// - public IDictionary Extensions { get; set; } = new Dictionary(); + public IDictionary? Extensions { get; set; } = new Dictionary(); /// /// Parameterless constructor @@ -78,7 +78,7 @@ public void SerializeAsV3(IOpenApiWriter writer) /// private void SerializeInternal(IOpenApiWriter writer, OpenApiSpecVersion version) { - Utils.CheckArgumentNull(writer);; + Utils.CheckArgumentNull(writer); writer.WriteStartObject(); diff --git a/src/Microsoft.OpenApi/Models/OpenApiOAuthFlows.cs b/src/Microsoft.OpenApi/Models/OpenApiOAuthFlows.cs index 5211159a4..758e1e02d 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiOAuthFlows.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiOAuthFlows.cs @@ -16,27 +16,27 @@ public class OpenApiOAuthFlows : IOpenApiSerializable, IOpenApiExtensible /// /// Configuration for the OAuth Implicit flow /// - public OpenApiOAuthFlow Implicit { get; set; } + public OpenApiOAuthFlow? Implicit { get; set; } /// /// Configuration for the OAuth Resource Owner Password flow. /// - public OpenApiOAuthFlow Password { get; set; } + public OpenApiOAuthFlow? Password { get; set; } /// /// Configuration for the OAuth Client Credentials flow. /// - public OpenApiOAuthFlow ClientCredentials { get; set; } + public OpenApiOAuthFlow? ClientCredentials { get; set; } /// /// Configuration for the OAuth Authorization Code flow. /// - public OpenApiOAuthFlow AuthorizationCode { get; set; } + public OpenApiOAuthFlow? AuthorizationCode { get; set; } /// /// Specification Extensions. /// - public IDictionary Extensions { get; set; } = new Dictionary(); + public IDictionary? Extensions { get; set; } = new Dictionary(); /// /// Parameterless constructor @@ -49,10 +49,10 @@ public OpenApiOAuthFlows() { } /// public OpenApiOAuthFlows(OpenApiOAuthFlows oAuthFlows) { - Implicit = oAuthFlows?.Implicit != null ? new(oAuthFlows?.Implicit) : null; - Password = oAuthFlows?.Password != null ? new(oAuthFlows?.Password) : null; - ClientCredentials = oAuthFlows?.ClientCredentials != null ? new(oAuthFlows?.ClientCredentials) : null; - AuthorizationCode = oAuthFlows?.AuthorizationCode != null ? new(oAuthFlows?.AuthorizationCode) : null; + Implicit = oAuthFlows?.Implicit != null ? new(oAuthFlows.Implicit) : null; + Password = oAuthFlows?.Password != null ? new(oAuthFlows.Password) : null; + ClientCredentials = oAuthFlows?.ClientCredentials != null ? new(oAuthFlows.ClientCredentials) : null; + AuthorizationCode = oAuthFlows?.AuthorizationCode != null ? new(oAuthFlows.AuthorizationCode) : null; Extensions = oAuthFlows?.Extensions != null ? new Dictionary(oAuthFlows.Extensions) : null; } @@ -78,7 +78,7 @@ public void SerializeAsV3(IOpenApiWriter writer) private void SerializeInternal(IOpenApiWriter writer, OpenApiSpecVersion version, Action callback) { - Utils.CheckArgumentNull(writer);; + Utils.CheckArgumentNull(writer); writer.WriteStartObject(); diff --git a/src/Microsoft.OpenApi/Models/OpenApiOperation.cs b/src/Microsoft.OpenApi/Models/OpenApiOperation.cs index 2ea920640..5375fb031 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiOperation.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiOperation.cs @@ -262,17 +262,18 @@ public void SerializeAsV2(IOpenApiWriter writer) if (consumes.Count > 0) { // This is form data. We need to split the request body into multiple parameters. - if (consumes.Contains("application/x-www-form-urlencoded") || - consumes.Contains("multipart/form-data")) + if ((consumes.Contains("application/x-www-form-urlencoded") || + consumes.Contains("multipart/form-data")) && + RequestBody.ConvertToFormDataParameters(writer) is { } formDataParameters) { - parameters.AddRange(RequestBody.ConvertToFormDataParameters(writer)); + parameters.AddRange(formDataParameters); } - else + else if (RequestBody.ConvertToBodyParameter(writer) is { } bodyParameter) { - parameters.Add(RequestBody.ConvertToBodyParameter(writer)); + parameters.Add(bodyParameter); } } - else if (RequestBody is OpenApiRequestBodyReference requestBodyReference) + else if (RequestBody is OpenApiRequestBodyReference requestBodyReference && requestBodyReference.Reference.Id is not null) { parameters.Add( new OpenApiParameterReference(requestBodyReference.Reference.Id, requestBodyReference.Reference.HostDocument)); @@ -336,7 +337,13 @@ public void SerializeAsV2(IOpenApiWriter writer) .Distinct() .ToList(); - writer.WriteOptionalCollection(OpenApiConstants.Schemes, schemes, (w, s) => w.WriteValue(s)); + writer.WriteOptionalCollection(OpenApiConstants.Schemes, schemes, (w, s) => + { + if (!string.IsNullOrEmpty(s) && s is not null) + { + w.WriteValue(s); + } + }); } // deprecated diff --git a/src/Microsoft.OpenApi/Models/OpenApiParameter.cs b/src/Microsoft.OpenApi/Models/OpenApiParameter.cs index da299e4b5..652e65b3d 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiParameter.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiParameter.cs @@ -23,13 +23,13 @@ public class OpenApiParameter : IOpenApiExtensible, IOpenApiParameter private ParameterStyle? _style; /// - public string Name { get; set; } + public string? Name { get; set; } /// public ParameterLocation? In { get; set; } /// - public string Description { get; set; } + public string? Description { get; set; } /// public bool Required { get; set; } @@ -58,19 +58,19 @@ public bool Explode public bool AllowReserved { get; set; } /// - public IOpenApiSchema Schema { get; set; } + public IOpenApiSchema? Schema { get; set; } /// - public IDictionary Examples { get; set; } = new Dictionary(); + public IDictionary? Examples { get; set; } = new Dictionary(); /// - public JsonNode Example { get; set; } + public JsonNode? Example { get; set; } /// - public IDictionary Content { get; set; } = new Dictionary(); + public IDictionary? Content { get; set; } = new Dictionary(); /// - public IDictionary Extensions { get; set; } = new Dictionary(); + public IDictionary? Extensions { get; set; } = new Dictionary(); /// /// A parameterless constructor @@ -90,7 +90,7 @@ internal OpenApiParameter(IOpenApiParameter parameter) Style = parameter.Style ?? Style; Explode = parameter.Explode; AllowReserved = parameter.AllowReserved; - Schema = parameter.Schema.CreateShallowCopy(); + Schema = parameter.Schema?.CreateShallowCopy(); Examples = parameter.Examples != null ? new Dictionary(parameter.Examples) : null; Example = parameter.Example != null ? JsonNodeCloneHelper.Clone(parameter.Example) : null; Content = parameter.Content != null ? new Dictionary(parameter.Content) : null; @@ -199,7 +199,7 @@ public void SerializeAsV2(IOpenApiWriter writer) // deprecated writer.WriteProperty(OpenApiConstants.Deprecated, Deprecated, false); - var extensionsClone = new Dictionary(Extensions); + var extensionsClone = Extensions is not null ? new Dictionary(Extensions) : null; // schema if (this is OpenApiBodyParameter) @@ -239,14 +239,14 @@ public void SerializeAsV2(IOpenApiWriter writer) if (targetSchema is not null) { targetSchema.WriteAsItemsProperties(writer); - var extensions = Schema.Extensions; + var extensions = Schema?.Extensions; if (extensions != null) { foreach (var key in extensions.Keys) { // The extension will already have been serialized as part of the call to WriteAsItemsProperties above, // so remove it from the cloned collection so we don't write it again. - extensionsClone.Remove(key); + extensionsClone?.Remove(key); } } } diff --git a/src/Microsoft.OpenApi/Models/OpenApiPathItem.cs b/src/Microsoft.OpenApi/Models/OpenApiPathItem.cs index 1d4be44ad..6e89d9684 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiPathItem.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiPathItem.cs @@ -17,23 +17,23 @@ namespace Microsoft.OpenApi.Models public class OpenApiPathItem : IOpenApiExtensible, IOpenApiReferenceable, IOpenApiPathItem { /// - public string Summary { get; set; } + public string? Summary { get; set; } /// - public string Description { get; set; } + public string? Description { get; set; } /// - public IDictionary Operations { get; set; } + public IDictionary? Operations { get; set; } = new Dictionary(); /// - public IList Servers { get; set; } = []; + public IList? Servers { get; set; } = []; /// - public IList Parameters { get; set; } = []; + public IList? Parameters { get; set; } = []; /// - public IDictionary Extensions { get; set; } = new Dictionary(); + public IDictionary? Extensions { get; set; } = new Dictionary(); /// /// Add one operation into this path item. @@ -42,7 +42,10 @@ public class OpenApiPathItem : IOpenApiExtensible, IOpenApiReferenceable, IOpenA /// The operation item. public void AddOperation(HttpMethod operationType, OpenApiOperation operation) { - Operations[operationType] = operation; + if (Operations is not null) + { + Operations[operationType] = operation; + } } /// @@ -91,14 +94,17 @@ public void SerializeAsV2(IOpenApiWriter writer) writer.WriteStartObject(); // operations except "trace" - foreach (var operation in Operations) + if (Operations != null) { - if (operation.Key != HttpMethod.Trace) + foreach (var operation in Operations) { - writer.WriteOptionalObject( - operation.Key.Method.ToLowerInvariant(), - operation.Value, - (w, o) => o.SerializeAsV2(w)); + if (operation.Key != HttpMethod.Trace) + { + writer.WriteOptionalObject( + operation.Key.Method.ToLowerInvariant(), + operation.Value, + (w, o) => o.SerializeAsV2(w)); + } } } @@ -133,12 +139,15 @@ internal virtual void SerializeInternal(IOpenApiWriter writer, OpenApiSpecVersio writer.WriteProperty(OpenApiConstants.Description, Description); // operations - foreach (var operation in Operations) + if (Operations != null) { - writer.WriteOptionalObject( + foreach (var operation in Operations) + { + writer.WriteOptionalObject( operation.Key.Method.ToLowerInvariant(), operation.Value, callback); + } } // servers diff --git a/src/Microsoft.OpenApi/Models/OpenApiReference.cs b/src/Microsoft.OpenApi/Models/OpenApiReference.cs index 00d992a9e..ae79cc10f 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiReference.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiReference.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System; @@ -20,14 +20,14 @@ public class OpenApiReference : IOpenApiSerializable, IOpenApiDescribedElement, /// A short summary which by default SHOULD override that of the referenced component. /// If the referenced object-type does not allow a summary field, then this field has no effect. /// - public string Summary { get; set; } + public string? Summary { get; set; } /// /// A description which by default SHOULD override that of the referenced component. /// CommonMark syntax MAY be used for rich text representation. /// If the referenced object-type does not allow a description field, then this field has no effect. /// - public string Description { get; set; } + public string? Description { get; set; } /// /// External resource in the reference. @@ -35,13 +35,13 @@ public class OpenApiReference : IOpenApiSerializable, IOpenApiDescribedElement, /// 1. a absolute/relative file path, for example: ../commons/pet.json /// 2. a Url, for example: http://localhost/pet.json /// - public string ExternalResource { get; init; } - + public string? ExternalResource { get; init; } + /// /// The element type referenced. /// /// This must be present if is not present. - public ReferenceType? Type { get; init; } + public ReferenceType Type { get; init; } /// /// The identifier of the reusable component of one particular ReferenceType. @@ -50,7 +50,7 @@ public class OpenApiReference : IOpenApiSerializable, IOpenApiDescribedElement, /// If ExternalResource is not present, this is the name of the component without the reference type name. /// For example, if the reference is '#/components/schemas/componentName', the Id is 'componentName'. /// - public string Id { get; init; } + public string? Id { get; init; } /// /// Gets a flag indicating whether this reference is an external reference. @@ -67,16 +67,16 @@ public class OpenApiReference : IOpenApiSerializable, IOpenApiDescribedElement, /// public bool IsFragment { get; init; } - private OpenApiDocument hostDocument; + private OpenApiDocument? hostDocument; /// /// The OpenApiDocument that is hosting the OpenApiReference instance. This is used to enable dereferencing the reference. /// - public OpenApiDocument HostDocument { get => hostDocument; init => hostDocument = value; } + public OpenApiDocument? HostDocument { get => hostDocument; init => hostDocument = value; } /// /// Gets the full reference string for v3.0. /// - public string ReferenceV3 + public string? ReferenceV3 { get { @@ -85,11 +85,6 @@ public string ReferenceV3 return GetExternalReferenceV3(); } - if (!Type.HasValue) - { - throw new ArgumentNullException(nameof(Type)); - } - if (Type == ReferenceType.Tag) { return Id; @@ -99,20 +94,20 @@ public string ReferenceV3 { return Id; } - if (Id.StartsWith("http://", StringComparison.OrdinalIgnoreCase) || - Id.StartsWith("https://", StringComparison.OrdinalIgnoreCase)) + if (!string.IsNullOrEmpty(Id) && Id is not null && Id.StartsWith("http://", StringComparison.OrdinalIgnoreCase) || + !string.IsNullOrEmpty(Id) && Id is not null && Id.StartsWith("https://", StringComparison.OrdinalIgnoreCase)) { return Id; } - return "#/components/" + Type.Value.GetDisplayName() + "/" + Id; + return "#/components/" + Type.GetDisplayName() + "/" + Id; } } /// /// Gets the full reference string for V2.0 /// - public string ReferenceV2 + public string? ReferenceV2 { get { @@ -121,11 +116,6 @@ public string ReferenceV2 return GetExternalReferenceV2(); } - if (!Type.HasValue) - { - throw new ArgumentNullException(nameof(Type)); - } - if (Type == ReferenceType.Tag) { return Id; @@ -136,7 +126,7 @@ public string ReferenceV2 return Id; } - return "#/" + GetReferenceTypeNameAsV2(Type.Value) + "/" + Id; + return "#/" + GetReferenceTypeNameAsV2(Type) + "/" + Id; } } @@ -183,11 +173,11 @@ public void SerializeAsV3(IOpenApiWriter writer) /// /// Serialize /// - private void SerializeInternal(IOpenApiWriter writer, Action callback = null) + private void SerializeInternal(IOpenApiWriter writer, Action? callback = null) { Utils.CheckArgumentNull(writer); - if (Type == ReferenceType.Tag) + if (Type == ReferenceType.Tag && !string.IsNullOrEmpty(ReferenceV3) && ReferenceV3 is not null) { // Write the string value only writer.WriteValue(ReferenceV3); @@ -213,14 +203,14 @@ public void SerializeAsV2(IOpenApiWriter writer) { Utils.CheckArgumentNull(writer); - if (Type == ReferenceType.Tag) + if (Type == ReferenceType.Tag && !string.IsNullOrEmpty(ReferenceV2) && ReferenceV2 is not null) { // Write the string value only writer.WriteValue(ReferenceV2); return; } - if (Type == ReferenceType.SecurityScheme) + if (Type == ReferenceType.SecurityScheme && !string.IsNullOrEmpty(ReferenceV2) && ReferenceV2 is not null) { // Write the string as property name writer.WritePropertyName(ReferenceV2); @@ -235,7 +225,7 @@ public void SerializeAsV2(IOpenApiWriter writer) writer.WriteEndObject(); } - private string GetExternalReferenceV3() + private string? GetExternalReferenceV3() { if (Id != null) { @@ -250,26 +240,23 @@ private string GetExternalReferenceV3() return Id; } - if (Type.HasValue) - { - return ExternalResource + "#/components/" + Type.Value.GetDisplayName() + "/"+ Id; - } + return ExternalResource + "#/components/" + Type.GetDisplayName() + "/"+ Id; } return ExternalResource; } - private string GetExternalReferenceV2() + private string? GetExternalReferenceV2() { - if (Id != null) + if (Id is not null) { - return ExternalResource + "#/" + GetReferenceTypeNameAsV2((ReferenceType)Type) + "/" + Id; + return ExternalResource + "#/" + GetReferenceTypeNameAsV2(Type) + "/" + Id; } return ExternalResource; } - private string GetReferenceTypeNameAsV2(ReferenceType type) + private static string? GetReferenceTypeNameAsV2(ReferenceType type) { return type switch { diff --git a/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs b/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs index 95f86dba3..70d1a1309 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs @@ -19,16 +19,16 @@ namespace Microsoft.OpenApi.Models public class OpenApiRequestBody : IOpenApiReferenceable, IOpenApiExtensible, IOpenApiRequestBody { /// - public string Description { get; set; } + public string? Description { get; set; } /// public bool Required { get; set; } /// - public IDictionary Content { get; set; } = new Dictionary(); + public IDictionary? Content { get; set; } = new Dictionary(); /// - public IDictionary Extensions { get; set; } = new Dictionary(); + public IDictionary? Extensions { get; set; } = new Dictionary(); /// /// Parameter-less constructor @@ -102,15 +102,17 @@ public IOpenApiParameter ConvertToBodyParameter(IOpenApiWriter writer) // V2 spec actually allows the body to have custom name. // To allow round-tripping we use an extension to hold the name Name = "body", - Schema = Content.Values.FirstOrDefault()?.Schema ?? new OpenApiSchema(), - Examples = Content.Values.FirstOrDefault()?.Examples, + Schema = Content?.Values.FirstOrDefault()?.Schema ?? new OpenApiSchema(), + Examples = Content?.Values.FirstOrDefault()?.Examples, Required = Required, - Extensions = Extensions.ToDictionary(static k => k.Key, static v => v.Value) // Clone extensions so we can remove the x-bodyName extensions from the output V2 model. + Extensions = Extensions?.ToDictionary(static k => k.Key, static v => v.Value) }; - if (bodyParameter.Extensions.ContainsKey(OpenApiConstants.BodyName)) + // Clone extensions so we can remove the x-bodyName extensions from the output V2 model. + if (bodyParameter.Extensions is not null && + bodyParameter.Extensions.TryGetValue(OpenApiConstants.BodyName, out var bodyNameExtension) && + bodyNameExtension is OpenApiAny bodyName) { - var bodyName = bodyParameter.Extensions[OpenApiConstants.BodyName] as OpenApiAny; - bodyParameter.Name = string.IsNullOrEmpty(bodyName?.Node.ToString()) ? "body" : bodyName?.Node.ToString(); + bodyParameter.Name = string.IsNullOrEmpty(bodyName.Node.ToString()) ? "body" : bodyName.Node.ToString(); bodyParameter.Extensions.Remove(OpenApiConstants.BodyName); } return bodyParameter; @@ -121,34 +123,41 @@ public IEnumerable ConvertToFormDataParameters(IOpenApiWriter { if (Content == null || !Content.Any()) yield break; - - foreach (var property in Content.First().Value.Schema.Properties) + var properties = Content.First().Value.Schema?.Properties; + if(properties != null) { - var paramSchema = property.Value.CreateShallowCopy(); - if ((paramSchema.Type & JsonSchemaType.String) == JsonSchemaType.String - && ("binary".Equals(paramSchema.Format, StringComparison.OrdinalIgnoreCase) - || "base64".Equals(paramSchema.Format, StringComparison.OrdinalIgnoreCase))) + foreach (var property in properties) { - var updatedSchema = paramSchema switch { - OpenApiSchema s => s, // we already have a copy - // we have a copy of a reference but don't want to mutate the source schema - // TODO might need recursive resolution of references here - OpenApiSchemaReference r => (OpenApiSchema)r.Target.CreateShallowCopy(), - _ => throw new InvalidOperationException("Unexpected schema type") + var paramSchema = property.Value.CreateShallowCopy(); + if ((paramSchema.Type & JsonSchemaType.String) == JsonSchemaType.String + && ("binary".Equals(paramSchema.Format, StringComparison.OrdinalIgnoreCase) + || "base64".Equals(paramSchema.Format, StringComparison.OrdinalIgnoreCase))) + { + var updatedSchema = paramSchema switch + { + OpenApiSchema s => s, // we already have a copy + // we have a copy of a reference but don't want to mutate the source schema + // TODO might need recursive resolution of references here + OpenApiSchemaReference r when r.Target is not null => (OpenApiSchema)r.Target.CreateShallowCopy(), + OpenApiSchemaReference => throw new InvalidOperationException("Unresolved reference target"), + _ => throw new InvalidOperationException("Unexpected schema type") + }; + + updatedSchema.Type = "file".ToJsonSchemaType(); + updatedSchema.Format = null; + paramSchema = updatedSchema; + + } + yield return new OpenApiFormDataParameter() + { + Description = paramSchema.Description, + Name = property.Key, + Schema = paramSchema, + Examples = Content.Values.FirstOrDefault()?.Examples, + Required = Content.First().Value.Schema?.Required?.Contains(property.Key) ?? false }; - updatedSchema.Type = "file".ToJsonSchemaType(); - updatedSchema.Format = null; - paramSchema = updatedSchema; } - yield return new OpenApiFormDataParameter() - { - Description = paramSchema.Description, - Name = property.Key, - Schema = paramSchema, - Examples = Content.Values.FirstOrDefault()?.Examples, - Required = Content.First().Value.Schema.Required?.Contains(property.Key) ?? false - }; - } + } } /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiResponse.cs b/src/Microsoft.OpenApi/Models/OpenApiResponse.cs index 0ec6cbb84..9c8459e2b 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiResponse.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiResponse.cs @@ -16,19 +16,19 @@ namespace Microsoft.OpenApi.Models public class OpenApiResponse : IOpenApiReferenceable, IOpenApiExtensible, IOpenApiResponse { /// - public string Description { get; set; } + public string? Description { get; set; } /// - public IDictionary Headers { get; set; } = new Dictionary(); + public IDictionary? Headers { get; set; } = new Dictionary(); /// - public IDictionary Content { get; set; } = new Dictionary(); + public IDictionary? Content { get; set; } = new Dictionary(); /// - public IDictionary Links { get; set; } = new Dictionary(); + public IDictionary? Links { get; set; } = new Dictionary(); /// - public IDictionary Extensions { get; set; } = new Dictionary(); + public IDictionary? Extensions { get; set; } = new Dictionary(); /// /// Parameterless constructor @@ -101,7 +101,7 @@ public void SerializeAsV2(IOpenApiWriter writer) // description writer.WriteRequiredProperty(OpenApiConstants.Description, Description); - var extensionsClone = new Dictionary(Extensions); + var extensionsClone = Extensions is not null ? new Dictionary(Extensions) : null; if (Content != null) { @@ -135,8 +135,9 @@ public void SerializeAsV2(IOpenApiWriter writer) writer.WriteStartObject(); foreach (var example in Content - .Where(mediaTypePair => mediaTypePair.Value.Examples != null && mediaTypePair.Value.Examples.Any()) - .SelectMany(mediaTypePair => mediaTypePair.Value.Examples)) + .Select(static x => x.Value.Examples) + .OfType>() + .SelectMany(static x => x)) { writer.WritePropertyName(example.Key); example.Value.SerializeAsV2(writer); @@ -147,12 +148,15 @@ public void SerializeAsV2(IOpenApiWriter writer) writer.WriteExtensions(mediatype.Value.Extensions, OpenApiSpecVersion.OpenApi2_0); - foreach (var key in mediatype.Value.Extensions.Keys) + if (mediatype.Value.Extensions is not null) { - // The extension will already have been serialized as part of the call above, - // so remove it from the cloned collection so we don't write it again. - extensionsClone.Remove(key); - } + foreach (var key in mediatype.Value.Extensions.Keys) + { + // The extension will already have been serialized as part of the call above, + // so remove it from the cloned collection so we don't write it again. + extensionsClone?.Remove(key); + } + } } } diff --git a/src/Microsoft.OpenApi/Models/OpenApiSchema.cs b/src/Microsoft.OpenApi/Models/OpenApiSchema.cs index 10f403efc..84e03fcb0 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiSchema.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiSchema.cs @@ -21,28 +21,28 @@ namespace Microsoft.OpenApi.Models public class OpenApiSchema : IOpenApiExtensible, IOpenApiSchema { /// - public string Title { get; set; } + public string? Title { get; set; } /// - public Uri Schema { get; set; } + public Uri? Schema { get; set; } /// - public string Id { get; set; } + public string? Id { get; set; } /// - public string Comment { get; set; } + public string? Comment { get; set; } /// - public IDictionary Vocabulary { get; set; } + public IDictionary? Vocabulary { get; set; } /// - public string DynamicRef { get; set; } + public string? DynamicRef { get; set; } /// - public string DynamicAnchor { get; set; } + public string? DynamicAnchor { get; set; } /// - public IDictionary Definitions { get; set; } + public IDictionary? Definitions { get; set; } private decimal? _exclusiveMaximum; /// @@ -109,13 +109,13 @@ public decimal? ExclusiveMinimum public JsonSchemaType? Type { get; set; } /// - public string Const { get; set; } + public string? Const { get; set; } /// - public string Format { get; set; } + public string? Format { get; set; } /// - public string Description { get; set; } + public string? Description { get; set; } private decimal? _maximum; /// @@ -161,13 +161,13 @@ public decimal? Minimum public int? MinLength { get; set; } /// - public string Pattern { get; set; } + public string? Pattern { get; set; } /// public decimal? MultipleOf { get; set; } /// - public JsonNode Default { get; set; } + public JsonNode? Default { get; set; } /// public bool ReadOnly { get; set; } @@ -176,22 +176,22 @@ public decimal? Minimum public bool WriteOnly { get; set; } /// - public IList AllOf { get; set; } = []; + public IList? AllOf { get; set; } = []; /// - public IList OneOf { get; set; } = []; + public IList? OneOf { get; set; } = []; /// - public IList AnyOf { get; set; } = []; + public IList? AnyOf { get; set; } = []; /// - public IOpenApiSchema Not { get; set; } + public IOpenApiSchema? Not { get; set; } /// - public ISet Required { get; set; } = new HashSet(); + public ISet? Required { get; set; } = new HashSet(); /// - public IOpenApiSchema Items { get; set; } + public IOpenApiSchema? Items { get; set; } /// public int? MaxItems { get; set; } @@ -203,10 +203,10 @@ public decimal? Minimum public bool? UniqueItems { get; set; } /// - public IDictionary Properties { get; set; } = new Dictionary(StringComparer.Ordinal); + public IDictionary? Properties { get; set; } = new Dictionary(StringComparer.Ordinal); /// - public IDictionary PatternProperties { get; set; } = new Dictionary(StringComparer.Ordinal); + public IDictionary? PatternProperties { get; set; } = new Dictionary(StringComparer.Ordinal); /// public int? MaxProperties { get; set; } @@ -218,43 +218,43 @@ public decimal? Minimum public bool AdditionalPropertiesAllowed { get; set; } = true; /// - public IOpenApiSchema AdditionalProperties { get; set; } + public IOpenApiSchema? AdditionalProperties { get; set; } /// - public OpenApiDiscriminator Discriminator { get; set; } + public OpenApiDiscriminator? Discriminator { get; set; } /// - public JsonNode Example { get; set; } + public JsonNode? Example { get; set; } /// - public IList Examples { get; set; } + public IList? Examples { get; set; } /// - public IList Enum { get; set; } = new List(); + public IList? Enum { get; set; } = new List(); /// public bool UnevaluatedProperties { get; set;} /// - public OpenApiExternalDocs ExternalDocs { get; set; } + public OpenApiExternalDocs? ExternalDocs { get; set; } /// public bool Deprecated { get; set; } /// - public OpenApiXml Xml { get; set; } + public OpenApiXml? Xml { get; set; } /// - public IDictionary Extensions { get; set; } = new Dictionary(); + public IDictionary? Extensions { get; set; } = new Dictionary(); /// - public IDictionary UnrecognizedKeywords { get; set; } = new Dictionary(); + public IDictionary? UnrecognizedKeywords { get; set; } = new Dictionary(); /// - public IDictionary Annotations { get; set; } + public IDictionary? Annotations { get; set; } /// - public IDictionary> DependentRequired { get; set; } = new Dictionary>(); + public IDictionary>? DependentRequired { get; set; } = new Dictionary>(); /// /// Parameterless constructor @@ -424,7 +424,13 @@ private void SerializeInternal(IOpenApiWriter writer, OpenApiSpecVersion version writer.WriteProperty(OpenApiConstants.MinProperties, MinProperties); // required - writer.WriteOptionalCollection(OpenApiConstants.Required, Required, (w, s) => w.WriteValue(s)); + writer.WriteOptionalCollection(OpenApiConstants.Required, Required, (w, s) => + { + if (!string.IsNullOrEmpty(s) && s is not null) + { + w.WriteValue(s); + } + }); // enum writer.WriteOptionalCollection(OpenApiConstants.Enum, Enum, (nodeWriter, s) => nodeWriter.WriteAny(s)); @@ -497,7 +503,7 @@ private void SerializeInternal(IOpenApiWriter writer, OpenApiSpecVersion version writer.WriteExtensions(Extensions, version); // Unrecognized keywords - if (UnrecognizedKeywords.Any()) + if (UnrecognizedKeywords is not null && UnrecognizedKeywords.Any()) { writer.WriteOptionalMap(OpenApiConstants.UnrecognizedKeywords, UnrecognizedKeywords, (w,s) => w.WriteAny(s)); } @@ -604,8 +610,8 @@ private void WriteFormatProperty(IOpenApiWriter writer) /// The property name that will be serialized. private void SerializeAsV2( IOpenApiWriter writer, - ISet parentRequiredProperties, - string propertyName) + ISet? parentRequiredProperties, + string? propertyName) { parentRequiredProperties ??= new HashSet(); @@ -662,7 +668,13 @@ private void SerializeAsV2( writer.WriteProperty(OpenApiConstants.MinProperties, MinProperties); // required - writer.WriteOptionalCollection(OpenApiConstants.Required, Required, (w, s) => w.WriteValue(s)); + writer.WriteOptionalCollection(OpenApiConstants.Required, Required, (w, s) => + { + if (!string.IsNullOrEmpty(s) && s is not null) + { + w.WriteValue(s); + } + }); // enum writer.WriteOptionalCollection(OpenApiConstants.Enum, Enum, (w, s) => w.WriteAny(s)); @@ -715,7 +727,7 @@ private void SerializeAsV2( // readOnly // In V2 schema if a property is part of required properties of parent schema, // it cannot be marked as readonly. - if (!parentRequiredProperties.Contains(propertyName)) + if (!string.IsNullOrEmpty(propertyName) && propertyName is not null && !parentRequiredProperties.Contains(propertyName)) { writer.WriteProperty(name: OpenApiConstants.ReadOnly, value: ReadOnly, defaultValue: false); } @@ -815,7 +827,13 @@ where temporaryType.HasFlag(flag) select flag.ToFirstIdentifier()).ToList(); if (list.Count > 1) { - writer.WriteOptionalCollection(OpenApiConstants.Type, list, (w, s) => w.WriteValue(s)); + writer.WriteOptionalCollection(OpenApiConstants.Type, list, (w, s) => + { + if (!string.IsNullOrEmpty(s) && s is not null) + { + w.WriteValue(s); + } + }); } else { diff --git a/src/Microsoft.OpenApi/Models/OpenApiSecurityRequirement.cs b/src/Microsoft.OpenApi/Models/OpenApiSecurityRequirement.cs index 193d648df..7b2e70d3c 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiSecurityRequirement.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiSecurityRequirement.cs @@ -37,7 +37,13 @@ public OpenApiSecurityRequirement() /// public void SerializeAsV31(IOpenApiWriter writer) { - SerializeInternal(writer, (w, s) => w.WritePropertyName(s.Reference.ReferenceV3)); + SerializeInternal(writer, (w, s) => + { + if(!string.IsNullOrEmpty(s.Reference.ReferenceV3) && s.Reference.ReferenceV3 is not null) + { + w.WritePropertyName(s.Reference.ReferenceV3); + } + }); } /// @@ -45,7 +51,13 @@ public void SerializeAsV31(IOpenApiWriter writer) /// public void SerializeAsV3(IOpenApiWriter writer) { - SerializeInternal(writer, (w, s) => w.WritePropertyName(s.Reference.ReferenceV3)); + SerializeInternal(writer, (w, s) => + { + if (!string.IsNullOrEmpty(s.Reference.ReferenceV3) && s.Reference.ReferenceV3 is not null) + { + w.WritePropertyName(s.Reference.ReferenceV3); + } + }); } /// @@ -98,7 +110,7 @@ private sealed class OpenApiSecuritySchemeReferenceEqualityComparer : IEqualityC /// /// Determines whether the specified objects are equal. /// - public bool Equals(OpenApiSecuritySchemeReference x, OpenApiSecuritySchemeReference y) + public bool Equals(OpenApiSecuritySchemeReference? x, OpenApiSecuritySchemeReference? y) { if (x == null && y == null) { @@ -122,7 +134,8 @@ public int GetHashCode(OpenApiSecuritySchemeReference obj) { return 0; } - return string.IsNullOrEmpty(obj?.Reference?.Id) ? 0 : obj.Reference.Id.GetHashCode(); + var id = obj.Reference?.Id; + return string.IsNullOrEmpty(id) ? 0 : id!.GetHashCode(); } } } diff --git a/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs b/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs index dddbbffec..7d254a3d2 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs @@ -19,28 +19,28 @@ public class OpenApiSecurityScheme : IOpenApiExtensible, IOpenApiReferenceable, public SecuritySchemeType? Type { get; set; } /// - public string Description { get; set; } + public string? Description { get; set; } /// - public string Name { get; set; } + public string? Name { get; set; } /// public ParameterLocation? In { get; set; } /// - public string Scheme { get; set; } + public string? Scheme { get; set; } /// - public string BearerFormat { get; set; } + public string? BearerFormat { get; set; } /// - public OpenApiOAuthFlows Flows { get; set; } + public OpenApiOAuthFlows? Flows { get; set; } /// - public Uri OpenIdConnectUrl { get; set; } + public Uri? OpenIdConnectUrl { get; set; } /// - public IDictionary Extensions { get; set; } = new Dictionary(); + public IDictionary? Extensions { get; set; } = new Dictionary(); /// /// Parameterless constructor @@ -88,7 +88,7 @@ private void SerializeInternal(IOpenApiWriter writer, OpenApiSpecVersion version writer.WriteStartObject(); // type - writer.WriteProperty(OpenApiConstants.Type, Type.GetDisplayName()); + writer.WriteProperty(OpenApiConstants.Type, Type?.GetDisplayName()); // description writer.WriteProperty(OpenApiConstants.Description, Description); @@ -100,7 +100,7 @@ private void SerializeInternal(IOpenApiWriter writer, OpenApiSpecVersion version // name // in writer.WriteProperty(OpenApiConstants.Name, Name); - writer.WriteProperty(OpenApiConstants.In, In.GetDisplayName()); + writer.WriteProperty(OpenApiConstants.In, In?.GetDisplayName()); break; case SecuritySchemeType.Http: // These properties apply to http type only. @@ -175,7 +175,7 @@ public void SerializeAsV2(IOpenApiWriter writer) // in writer.WriteProperty(OpenApiConstants.Type, Type.GetDisplayName()); writer.WriteProperty(OpenApiConstants.Name, Name); - writer.WriteProperty(OpenApiConstants.In, In.GetDisplayName()); + writer.WriteProperty(OpenApiConstants.In, In?.GetDisplayName()); break; } @@ -192,7 +192,7 @@ public void SerializeAsV2(IOpenApiWriter writer) /// Arbitrarily chooses one object from the /// to populate in V2 security scheme. /// - private static void WriteOAuthFlowForV2(IOpenApiWriter writer, OpenApiOAuthFlows flows) + private static void WriteOAuthFlowForV2(IOpenApiWriter writer, OpenApiOAuthFlows? flows) { if (flows != null) { diff --git a/src/Microsoft.OpenApi/Models/OpenApiServer.cs b/src/Microsoft.OpenApi/Models/OpenApiServer.cs index b580f7fbb..a15c6068e 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiServer.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiServer.cs @@ -16,25 +16,25 @@ public class OpenApiServer : IOpenApiSerializable, IOpenApiExtensible /// /// An optional string describing the host designated by the URL. CommonMark syntax MAY be used for rich text representation. /// - public string Description { get; set; } + public string? Description { get; set; } /// /// REQUIRED. A URL to the target host. This URL supports Server Variables and MAY be relative, /// to indicate that the host location is relative to the location where the OpenAPI document is being served. /// Variable substitutions will be made when a variable is named in {brackets}. /// - public string Url { get; set; } + public string? Url { get; set; } /// /// A map between a variable name and its value. The value is used for substitution in the server's URL template. /// - public IDictionary Variables { get; set; } = + public IDictionary? Variables { get; set; } = new Dictionary(); /// /// This object MAY be extended with Specification Extensions. /// - public IDictionary Extensions { get; set; } = new Dictionary(); + public IDictionary? Extensions { get; set; } = new Dictionary(); /// /// Parameterless constructor @@ -74,7 +74,7 @@ public void SerializeAsV3(IOpenApiWriter writer) private void SerializeInternal(IOpenApiWriter writer, OpenApiSpecVersion version, Action callback) { - Utils.CheckArgumentNull(writer);; + Utils.CheckArgumentNull(writer); writer.WriteStartObject(); diff --git a/src/Microsoft.OpenApi/Models/OpenApiServerVariable.cs b/src/Microsoft.OpenApi/Models/OpenApiServerVariable.cs index 615b8dc37..9c46f20a8 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiServerVariable.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiServerVariable.cs @@ -15,13 +15,13 @@ public class OpenApiServerVariable : IOpenApiSerializable, IOpenApiExtensible /// /// An optional description for the server variable. CommonMark syntax MAY be used for rich text representation. /// - public string Description { get; set; } + public string? Description { get; set; } /// /// REQUIRED. The default value to use for substitution, and to send, if an alternate value is not supplied. /// Unlike the Schema Object's default, this value MUST be provided by the consumer. /// - public string Default { get; set; } + public string? Default { get; set; } /// /// An enumeration of string values to be used if the substitution options are from a limited set. @@ -29,12 +29,12 @@ public class OpenApiServerVariable : IOpenApiSerializable, IOpenApiExtensible /// /// If the server variable in the OpenAPI document has no enum member, this property will be null. /// - public List Enum { get; set; } + public List? Enum { get; set; } /// /// This object MAY be extended with Specification Extensions. /// - public IDictionary Extensions { get; set; } = new Dictionary(); + public IDictionary? Extensions { get; set; } = new Dictionary(); /// /// Parameterless constructor @@ -48,8 +48,8 @@ public OpenApiServerVariable(OpenApiServerVariable serverVariable) { Description = serverVariable?.Description; Default = serverVariable?.Default; - Enum = serverVariable?.Enum != null ? new(serverVariable?.Enum) : serverVariable?.Enum; - Extensions = serverVariable?.Extensions != null ? new Dictionary(serverVariable?.Extensions) : serverVariable?.Extensions; + Enum = serverVariable?.Enum != null ? new(serverVariable.Enum) : serverVariable?.Enum; + Extensions = serverVariable?.Extensions != null ? new Dictionary(serverVariable.Extensions) : serverVariable?.Extensions; } /// @@ -73,7 +73,7 @@ public void SerializeAsV3(IOpenApiWriter writer) /// private void SerializeInternal(IOpenApiWriter writer, OpenApiSpecVersion version) { - Utils.CheckArgumentNull(writer);; + Utils.CheckArgumentNull(writer); writer.WriteStartObject(); @@ -84,7 +84,13 @@ private void SerializeInternal(IOpenApiWriter writer, OpenApiSpecVersion version writer.WriteProperty(OpenApiConstants.Description, Description); // enums - writer.WriteOptionalCollection(OpenApiConstants.Enum, Enum, (w, s) => w.WriteValue(s)); + writer.WriteOptionalCollection(OpenApiConstants.Enum, Enum, (w, s) => + { + if (!string.IsNullOrEmpty(s) && s is not null) + { + w.WriteValue(s); + } + }); // specification extensions writer.WriteExtensions(Extensions, version); diff --git a/src/Microsoft.OpenApi/Models/OpenApiTag.cs b/src/Microsoft.OpenApi/Models/OpenApiTag.cs index 91e3aac68..48ac2960c 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiTag.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiTag.cs @@ -15,16 +15,16 @@ namespace Microsoft.OpenApi.Models public class OpenApiTag : IOpenApiExtensible, IOpenApiReferenceable, IOpenApiTag, IOpenApiDescribedElement { /// - public string Name { get; set; } + public string? Name { get; set; } /// - public string Description { get; set; } + public string? Description { get; set; } /// - public OpenApiExternalDocs ExternalDocs { get; set; } + public OpenApiExternalDocs? ExternalDocs { get; set; } /// - public IDictionary Extensions { get; set; } = new Dictionary(); + public IDictionary? Extensions { get; set; } = new Dictionary(); /// /// Parameterless constructor diff --git a/src/Microsoft.OpenApi/Models/OpenApiXml.cs b/src/Microsoft.OpenApi/Models/OpenApiXml.cs index d0ee6a00b..c0503e14d 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiXml.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiXml.cs @@ -16,17 +16,17 @@ public class OpenApiXml : IOpenApiSerializable, IOpenApiExtensible /// /// Replaces the name of the element/attribute used for the described schema property. /// - public string Name { get; set; } + public string? Name { get; set; } /// /// The URI of the namespace definition. Value MUST be in the form of an absolute URI. /// - public Uri Namespace { get; set; } + public Uri? Namespace { get; set; } /// /// The prefix to be used for the name /// - public string Prefix { get; set; } + public string? Prefix { get; set; } /// /// Declares whether the property definition translates to an attribute instead of an element. @@ -43,7 +43,7 @@ public class OpenApiXml : IOpenApiSerializable, IOpenApiExtensible /// /// Specification Extensions. /// - public IDictionary Extensions { get; set; } = new Dictionary(); + public IDictionary? Extensions { get; set; } = new Dictionary(); /// /// Parameterless constructor @@ -89,7 +89,7 @@ public void SerializeAsV2(IOpenApiWriter writer) private void Write(IOpenApiWriter writer, OpenApiSpecVersion specVersion) { - Utils.CheckArgumentNull(writer);; + Utils.CheckArgumentNull(writer); writer.WriteStartObject(); diff --git a/src/Microsoft.OpenApi/Models/References/BaseOpenApiReferenceHolder.cs b/src/Microsoft.OpenApi/Models/References/BaseOpenApiReferenceHolder.cs index ea1839f49..167dcf2c3 100644 --- a/src/Microsoft.OpenApi/Models/References/BaseOpenApiReferenceHolder.cs +++ b/src/Microsoft.OpenApi/Models/References/BaseOpenApiReferenceHolder.cs @@ -11,7 +11,7 @@ namespace Microsoft.OpenApi.Models.References; public abstract class BaseOpenApiReferenceHolder : IOpenApiReferenceHolder where T : class, IOpenApiReferenceable, V where V : IOpenApiReferenceable, IOpenApiSerializable { /// - public virtual V Target + public virtual V? Target { get { @@ -20,7 +20,7 @@ public virtual V Target } } /// - public T RecursiveTarget + public T? RecursiveTarget { get { @@ -31,6 +31,7 @@ public T RecursiveTarget }; } } + /// /// Copy constructor /// @@ -38,7 +39,7 @@ public T RecursiveTarget protected BaseOpenApiReferenceHolder(BaseOpenApiReferenceHolder source) { Utils.CheckArgumentNull(source); - Reference = source.Reference != null ? new(source.Reference) : null; + Reference = new(source.Reference); //no need to copy summary and description as if they are not overridden, they will be fetched from the target //if they are, the reference copy will handle it } @@ -53,7 +54,7 @@ protected BaseOpenApiReferenceHolder(BaseOpenApiReferenceHolder source) /// 1. a absolute/relative file path, for example: ../commons/pet.json /// 2. a Url, for example: http://localhost/pet.json /// - protected BaseOpenApiReferenceHolder(string referenceId, OpenApiDocument hostDocument, ReferenceType referenceType, string externalResource) + protected BaseOpenApiReferenceHolder(string referenceId, OpenApiDocument? hostDocument, ReferenceType referenceType, string? externalResource) { Utils.CheckArgumentNullOrEmpty(referenceId); // we're not checking for null hostDocument as it's optional and can be set via additional methods by a walker @@ -69,8 +70,14 @@ protected BaseOpenApiReferenceHolder(string referenceId, OpenApiDocument hostDoc } /// public bool UnresolvedReference { get => Reference is null || Target is null; } + +#if NETSTANDARD2_1_OR_GREATER + /// + public required OpenApiReference Reference { get; init; } +#else /// public OpenApiReference Reference { get; init; } +#endif /// public abstract V CopyReferenceAsTargetElementWithOverrides(V source); /// @@ -83,7 +90,7 @@ public virtual void SerializeAsV3(IOpenApiWriter writer) } else { - SerializeInternal(writer, (writer, element) => element.SerializeAsV3(writer)); + SerializeInternal(writer, (writer, element) => element?.SerializeAsV3(writer)); } } @@ -109,7 +116,7 @@ public virtual void SerializeAsV2(IOpenApiWriter writer) } else { - SerializeInternal(writer, (writer, element) => element.SerializeAsV2(writer)); + SerializeInternal(writer, (writer, element) => element?.SerializeAsV2(writer)); } } @@ -123,6 +130,9 @@ private protected void SerializeInternal(IOpenApiWriter writer, Action action) { Utils.CheckArgumentNull(writer); - action(writer, Target); + if (Target is not null) + { + action(writer, Target); + } } } diff --git a/src/Microsoft.OpenApi/Models/References/OpenApiCallbackReference.cs b/src/Microsoft.OpenApi/Models/References/OpenApiCallbackReference.cs index 4c30328d4..d1a06da15 100644 --- a/src/Microsoft.OpenApi/Models/References/OpenApiCallbackReference.cs +++ b/src/Microsoft.OpenApi/Models/References/OpenApiCallbackReference.cs @@ -25,7 +25,7 @@ public class OpenApiCallbackReference : BaseOpenApiReferenceHolder - public OpenApiCallbackReference(string referenceId, OpenApiDocument hostDocument = null, string externalResource = null):base(referenceId, hostDocument, ReferenceType.Callback, externalResource) + public OpenApiCallbackReference(string referenceId, OpenApiDocument? hostDocument = null, string? externalResource = null):base(referenceId, hostDocument, ReferenceType.Callback, externalResource) { } /// @@ -38,10 +38,10 @@ private OpenApiCallbackReference(OpenApiCallbackReference callback):base(callbac } /// - public Dictionary PathItems { get => Target?.PathItems; } + public Dictionary? PathItems { get => Target?.PathItems; } /// - public IDictionary Extensions { get => Target?.Extensions; } + public IDictionary? Extensions { get => Target?.Extensions; } /// public override IOpenApiCallback CopyReferenceAsTargetElementWithOverrides(IOpenApiCallback source) diff --git a/src/Microsoft.OpenApi/Models/References/OpenApiExampleReference.cs b/src/Microsoft.OpenApi/Models/References/OpenApiExampleReference.cs index edfe27b61..b1c1ae8ae 100644 --- a/src/Microsoft.OpenApi/Models/References/OpenApiExampleReference.cs +++ b/src/Microsoft.OpenApi/Models/References/OpenApiExampleReference.cs @@ -25,7 +25,7 @@ public class OpenApiExampleReference : BaseOpenApiReferenceHolder - public OpenApiExampleReference(string referenceId, OpenApiDocument hostDocument = null, string externalResource = null):base(referenceId, hostDocument, ReferenceType.Example, externalResource) + public OpenApiExampleReference(string referenceId, OpenApiDocument? hostDocument = null, string? externalResource = null):base(referenceId, hostDocument, ReferenceType.Example, externalResource) { } /// @@ -37,39 +37,27 @@ private OpenApiExampleReference(OpenApiExampleReference example):base(example) } /// - public string Description + public string? Description { - get => string.IsNullOrEmpty(Reference?.Description) ? Target?.Description : Reference.Description; - set - { - if (Reference is not null) - { - Reference.Description = value; - } - } + get => string.IsNullOrEmpty(Reference.Description) ? Target?.Description : Reference.Description; + set => Reference.Description = value; } /// - public string Summary + public string? Summary { - get => string.IsNullOrEmpty(Reference?.Summary) ? Target?.Summary : Reference.Summary; - set - { - if (Reference is not null) - { - Reference.Summary = value; - } - } + get => string.IsNullOrEmpty(Reference.Summary) ? Target?.Summary : Reference.Summary; + set => Reference.Summary = value; } /// - public IDictionary Extensions { get => Target?.Extensions; } + public IDictionary? Extensions { get => Target?.Extensions; } /// - public string ExternalValue { get => Target?.ExternalValue; } + public string? ExternalValue { get => Target?.ExternalValue; } /// - public JsonNode Value { get => Target?.Value; } + public JsonNode? Value { get => Target?.Value; } /// public override IOpenApiExample CopyReferenceAsTargetElementWithOverrides(IOpenApiExample source) diff --git a/src/Microsoft.OpenApi/Models/References/OpenApiHeaderReference.cs b/src/Microsoft.OpenApi/Models/References/OpenApiHeaderReference.cs index 719cdce3a..cd843de57 100644 --- a/src/Microsoft.OpenApi/Models/References/OpenApiHeaderReference.cs +++ b/src/Microsoft.OpenApi/Models/References/OpenApiHeaderReference.cs @@ -24,7 +24,7 @@ public class OpenApiHeaderReference : BaseOpenApiReferenceHolder - public OpenApiHeaderReference(string referenceId, OpenApiDocument hostDocument = null, string externalResource = null):base(referenceId, hostDocument, ReferenceType.Header, externalResource) + public OpenApiHeaderReference(string referenceId, OpenApiDocument? hostDocument = null, string? externalResource = null):base(referenceId, hostDocument, ReferenceType.Header, externalResource) { } @@ -37,16 +37,10 @@ private OpenApiHeaderReference(OpenApiHeaderReference header):base(header) } /// - public string Description + public string? Description { - get => string.IsNullOrEmpty(Reference?.Description) ? Target?.Description : Reference.Description; - set - { - if (Reference is not null) - { - Reference.Description = value; - } - } + get => string.IsNullOrEmpty(Reference.Description) ? Target?.Description : Reference.Description; + set => Reference.Description = value; } /// @@ -59,7 +53,7 @@ public string Description public bool AllowEmptyValue { get => Target?.AllowEmptyValue ?? default; } /// - public IOpenApiSchema Schema { get => Target?.Schema; } + public IOpenApiSchema? Schema { get => Target?.Schema; } /// public ParameterStyle? Style { get => Target?.Style; } @@ -71,16 +65,16 @@ public string Description public bool AllowReserved { get => Target?.AllowReserved ?? default; } /// - public JsonNode Example { get => Target?.Example; } + public JsonNode? Example { get => Target?.Example; } /// - public IDictionary Examples { get => Target?.Examples; } + public IDictionary? Examples { get => Target?.Examples; } /// - public IDictionary Content { get => Target?.Content; } + public IDictionary? Content { get => Target?.Content; } /// - public IDictionary Extensions { get => Target?.Extensions; } + public IDictionary? Extensions { get => Target?.Extensions; } /// public override IOpenApiHeader CopyReferenceAsTargetElementWithOverrides(IOpenApiHeader source) diff --git a/src/Microsoft.OpenApi/Models/References/OpenApiLinkReference.cs b/src/Microsoft.OpenApi/Models/References/OpenApiLinkReference.cs index f91b5711b..8c23cdf35 100644 --- a/src/Microsoft.OpenApi/Models/References/OpenApiLinkReference.cs +++ b/src/Microsoft.OpenApi/Models/References/OpenApiLinkReference.cs @@ -24,7 +24,7 @@ public class OpenApiLinkReference : BaseOpenApiReferenceHolder - public OpenApiLinkReference(string referenceId, OpenApiDocument hostDocument = null, string externalResource = null):base(referenceId, hostDocument, ReferenceType.Link, externalResource) + public OpenApiLinkReference(string referenceId, OpenApiDocument? hostDocument = null, string? externalResource = null):base(referenceId, hostDocument, ReferenceType.Link, externalResource) { } /// @@ -36,35 +36,29 @@ private OpenApiLinkReference(OpenApiLinkReference reference):base(reference) } /// - public string Description + public string? Description { - get => string.IsNullOrEmpty(Reference?.Description) ? Target?.Description : Reference.Description; - set - { - if (Reference is not null) - { - Reference.Description = value; - } - } + get => string.IsNullOrEmpty(Reference.Description) ? Target?.Description : Reference.Description; + set => Reference.Description = value; } /// - public string OperationRef { get => Target?.OperationRef; } + public string? OperationRef { get => Target?.OperationRef; } /// - public string OperationId { get => Target?.OperationId; } + public string? OperationId { get => Target?.OperationId; } /// - public OpenApiServer Server { get => Target?.Server; } + public OpenApiServer? Server { get => Target?.Server; } /// - public IDictionary Parameters { get => Target?.Parameters; } + public IDictionary? Parameters { get => Target?.Parameters; } /// - public RuntimeExpressionAnyWrapper RequestBody { get => Target?.RequestBody; } + public RuntimeExpressionAnyWrapper? RequestBody { get => Target?.RequestBody; } /// - public IDictionary Extensions { get => Target?.Extensions; } + public IDictionary? Extensions { get => Target?.Extensions; } /// public override void SerializeAsV2(IOpenApiWriter writer) diff --git a/src/Microsoft.OpenApi/Models/References/OpenApiParameterReference.cs b/src/Microsoft.OpenApi/Models/References/OpenApiParameterReference.cs index d337b841e..40ecb69eb 100644 --- a/src/Microsoft.OpenApi/Models/References/OpenApiParameterReference.cs +++ b/src/Microsoft.OpenApi/Models/References/OpenApiParameterReference.cs @@ -23,7 +23,7 @@ public class OpenApiParameterReference : BaseOpenApiReferenceHolder - public OpenApiParameterReference(string referenceId, OpenApiDocument hostDocument = null, string externalResource = null):base(referenceId, hostDocument, ReferenceType.Parameter, externalResource) + public OpenApiParameterReference(string referenceId, OpenApiDocument? hostDocument = null, string? externalResource = null):base(referenceId, hostDocument, ReferenceType.Parameter, externalResource) { } @@ -36,19 +36,13 @@ private OpenApiParameterReference(OpenApiParameterReference parameter):base(para } /// - public string Name { get => Target?.Name; } + public string? Name { get => Target?.Name; } /// - public string Description + public string? Description { - get => string.IsNullOrEmpty(Reference?.Description) ? Target?.Description : Reference.Description; - set - { - if (Reference is not null) - { - Reference.Description = value; - } - } + get => string.IsNullOrEmpty(Reference.Description) ? Target?.Description : Reference.Description; + set => Reference.Description = value; } /// @@ -64,13 +58,13 @@ public string Description public bool AllowReserved { get => Target?.AllowReserved ?? default; } /// - public IOpenApiSchema Schema { get => Target?.Schema; } + public IOpenApiSchema? Schema { get => Target?.Schema; } /// - public IDictionary Examples { get => Target?.Examples; } + public IDictionary? Examples { get => Target?.Examples; } /// - public JsonNode Example { get => Target?.Example; } + public JsonNode? Example { get => Target?.Example; } /// public ParameterLocation? In { get => Target?.In; } @@ -82,13 +76,13 @@ public string Description public bool Explode { get => Target?.Explode ?? default; } /// - public IDictionary Content { get => Target?.Content; } + public IDictionary? Content { get => Target?.Content; } /// - public IDictionary Extensions { get => Target?.Extensions; } + public IDictionary? Extensions { get => Target?.Extensions; } /// - public override IOpenApiParameter CopyReferenceAsTargetElementWithOverrides(IOpenApiParameter source) + public override IOpenApiParameter CopyReferenceAsTargetElementWithOverrides(IOpenApiParameter source) { return source is OpenApiParameter ? new OpenApiParameter(this) : source; } diff --git a/src/Microsoft.OpenApi/Models/References/OpenApiPathItemReference.cs b/src/Microsoft.OpenApi/Models/References/OpenApiPathItemReference.cs index d56d07c21..bfd9f8ceb 100644 --- a/src/Microsoft.OpenApi/Models/References/OpenApiPathItemReference.cs +++ b/src/Microsoft.OpenApi/Models/References/OpenApiPathItemReference.cs @@ -25,7 +25,7 @@ public class OpenApiPathItemReference : BaseOpenApiReferenceHolder - public OpenApiPathItemReference(string referenceId, OpenApiDocument hostDocument = null, string externalResource = null): base(referenceId, hostDocument, ReferenceType.PathItem, externalResource) + public OpenApiPathItemReference(string referenceId, OpenApiDocument? hostDocument = null, string? externalResource = null): base(referenceId, hostDocument, ReferenceType.PathItem, externalResource) { } @@ -39,42 +39,30 @@ private OpenApiPathItemReference(OpenApiPathItemReference pathItem):base(pathIte } /// - public string Summary + public string? Summary { - get => string.IsNullOrEmpty(Reference?.Summary) ? Target?.Summary : Reference.Summary; - set - { - if (Reference is not null) - { - Reference.Summary = value; - } - } + get => string.IsNullOrEmpty(Reference.Summary) ? Target?.Summary : Reference.Summary; + set => Reference.Summary = value; } /// - public string Description + public string? Description { - get => string.IsNullOrEmpty(Reference?.Description) ? Target?.Description : Reference.Description; - set - { - if (Reference is not null) - { - Reference.Description = value; - } - } + get => string.IsNullOrEmpty(Reference.Description) ? Target?.Description : Reference.Description; + set => Reference.Description = value; } /// - public IDictionary Operations { get => Target?.Operations; } + public IDictionary? Operations { get => Target?.Operations; } /// - public IList Servers { get => Target?.Servers; } + public IList? Servers { get => Target?.Servers; } /// - public IList Parameters { get => Target?.Parameters; } + public IList? Parameters { get => Target?.Parameters; } /// - public IDictionary Extensions { get => Target?.Extensions; } + public IDictionary? Extensions { get => Target?.Extensions; } /// public override IOpenApiPathItem CopyReferenceAsTargetElementWithOverrides(IOpenApiPathItem source) diff --git a/src/Microsoft.OpenApi/Models/References/OpenApiRequestBodyReference.cs b/src/Microsoft.OpenApi/Models/References/OpenApiRequestBodyReference.cs index 966d3aad1..8beb3e604 100644 --- a/src/Microsoft.OpenApi/Models/References/OpenApiRequestBodyReference.cs +++ b/src/Microsoft.OpenApi/Models/References/OpenApiRequestBodyReference.cs @@ -25,7 +25,7 @@ public class OpenApiRequestBodyReference : BaseOpenApiReferenceHolder - public OpenApiRequestBodyReference(string referenceId, OpenApiDocument hostDocument = null, string externalResource = null):base(referenceId, hostDocument, ReferenceType.RequestBody, externalResource) + public OpenApiRequestBodyReference(string referenceId, OpenApiDocument? hostDocument = null, string? externalResource = null):base(referenceId, hostDocument, ReferenceType.RequestBody, externalResource) { } /// @@ -38,26 +38,20 @@ private OpenApiRequestBodyReference(OpenApiRequestBodyReference openApiRequestBo } /// - public string Description + public string? Description { - get => string.IsNullOrEmpty(Reference?.Description) ? Target?.Description : Reference.Description; - set - { - if (Reference is not null) - { - Reference.Description = value; - } - } + get => string.IsNullOrEmpty(Reference.Description) ? Target?.Description : Reference.Description; + set => Reference.Description = value; } /// - public IDictionary Content { get => Target?.Content; } + public IDictionary? Content { get => Target?.Content; } /// public bool Required { get => Target?.Required ?? false; } /// - public IDictionary Extensions { get => Target?.Extensions; } + public IDictionary? Extensions { get => Target?.Extensions; } /// public override IOpenApiRequestBody CopyReferenceAsTargetElementWithOverrides(IOpenApiRequestBody source) @@ -70,29 +64,27 @@ public override void SerializeAsV2(IOpenApiWriter writer) // doesn't exist in v2 } /// - public IOpenApiParameter ConvertToBodyParameter(IOpenApiWriter writer) + public IOpenApiParameter? ConvertToBodyParameter(IOpenApiWriter writer) { if (writer.GetSettings().ShouldInlineReference(Reference)) { - return Target.ConvertToBodyParameter(writer); - } - else - { - return new OpenApiParameterReference(Reference.Id, Reference.HostDocument); + return Target?.ConvertToBodyParameter(writer); } + + return Reference.Id is not null ? new OpenApiParameterReference(Reference.Id, Reference.HostDocument) : null; } /// - public IEnumerable ConvertToFormDataParameters(IOpenApiWriter writer) + public IEnumerable? ConvertToFormDataParameters(IOpenApiWriter writer) { if (writer.GetSettings().ShouldInlineReference(Reference)) { - return Target.ConvertToFormDataParameters(writer); + return Target?.ConvertToFormDataParameters(writer); } if (Content == null || !Content.Any()) return []; - return Content.First().Value.Schema.Properties.Select(x => new OpenApiParameterReference(x.Key, Reference.HostDocument)); + return Content.First().Value.Schema?.Properties?.Select(x => new OpenApiParameterReference(x.Key, Reference.HostDocument)); } /// diff --git a/src/Microsoft.OpenApi/Models/References/OpenApiResponseReference.cs b/src/Microsoft.OpenApi/Models/References/OpenApiResponseReference.cs index 9fbfb47a0..cc78f6080 100644 --- a/src/Microsoft.OpenApi/Models/References/OpenApiResponseReference.cs +++ b/src/Microsoft.OpenApi/Models/References/OpenApiResponseReference.cs @@ -23,7 +23,7 @@ public class OpenApiResponseReference : BaseOpenApiReferenceHolder - public OpenApiResponseReference(string referenceId, OpenApiDocument hostDocument = null, string externalResource = null):base(referenceId, hostDocument, ReferenceType.Response, externalResource) + public OpenApiResponseReference(string referenceId, OpenApiDocument? hostDocument = null, string? externalResource = null):base(referenceId, hostDocument, ReferenceType.Response, externalResource) { } /// @@ -36,29 +36,23 @@ private OpenApiResponseReference(OpenApiResponseReference openApiResponseReferen } /// - public string Description + public string? Description { - get => string.IsNullOrEmpty(Reference?.Description) ? Target?.Description : Reference.Description; - set - { - if (Reference is not null) - { - Reference.Description = value; - } - } + get => string.IsNullOrEmpty(Reference.Description) ? Target?.Description : Reference.Description; + set => Reference.Description = value; } /// - public IDictionary Content { get => Target?.Content; } + public IDictionary? Content { get => Target?.Content; } /// - public IDictionary Headers { get => Target?.Headers; } + public IDictionary? Headers { get => Target?.Headers; } /// - public IDictionary Links { get => Target?.Links; } + public IDictionary? Links { get => Target?.Links; } /// - public IDictionary Extensions { get => Target?.Extensions; } + public IDictionary? Extensions { get => Target?.Extensions; } /// public override IOpenApiResponse CopyReferenceAsTargetElementWithOverrides(IOpenApiResponse source) diff --git a/src/Microsoft.OpenApi/Models/References/OpenApiSchemaReference.cs b/src/Microsoft.OpenApi/Models/References/OpenApiSchemaReference.cs index 8a5a84d93..2873065fd 100644 --- a/src/Microsoft.OpenApi/Models/References/OpenApiSchemaReference.cs +++ b/src/Microsoft.OpenApi/Models/References/OpenApiSchemaReference.cs @@ -25,7 +25,7 @@ public class OpenApiSchemaReference : BaseOpenApiReferenceHolder - public OpenApiSchemaReference(string referenceId, OpenApiDocument hostDocument = null, string externalResource = null):base(referenceId, hostDocument, ReferenceType.Schema, externalResource) + public OpenApiSchemaReference(string referenceId, OpenApiDocument? hostDocument = null, string? externalResource = null):base(referenceId, hostDocument, ReferenceType.Schema, externalResource) { } /// @@ -37,34 +37,28 @@ private OpenApiSchemaReference(OpenApiSchemaReference schema):base(schema) } /// - public string Description + public string? Description { - get => string.IsNullOrEmpty(Reference?.Description) ? Target?.Description : Reference.Description; - set - { - if (Reference is not null) - { - Reference.Description = value; - } - } + get => string.IsNullOrEmpty(Reference.Description) ? Target?.Description : Reference.Description; + set => Reference.Description = value; } /// - public string Title { get => Target?.Title; } + public string? Title { get => Target?.Title; } /// - public Uri Schema { get => Target?.Schema; } + public Uri? Schema { get => Target?.Schema; } /// - public string Id { get => Target?.Id; } + public string? Id { get => Target?.Id; } /// - public string Comment { get => Target?.Comment; } + public string? Comment { get => Target?.Comment; } /// - public IDictionary Vocabulary { get => Target?.Vocabulary; } + public IDictionary? Vocabulary { get => Target?.Vocabulary; } /// - public string DynamicRef { get => Target?.DynamicRef; } + public string? DynamicRef { get => Target?.DynamicRef; } /// - public string DynamicAnchor { get => Target?.DynamicAnchor; } + public string? DynamicAnchor { get => Target?.DynamicAnchor; } /// - public IDictionary Definitions { get => Target?.Definitions; } + public IDictionary? Definitions { get => Target?.Definitions; } /// public decimal? ExclusiveMaximum { get => Target?.ExclusiveMaximum; } /// @@ -74,9 +68,9 @@ public string Description /// public JsonSchemaType? Type { get => Target?.Type; } /// - public string Const { get => Target?.Const; } + public string? Const { get => Target?.Const; } /// - public string Format { get => Target?.Format; } + public string? Format { get => Target?.Format; } /// public decimal? Maximum { get => Target?.Maximum; } /// @@ -86,27 +80,27 @@ public string Description /// public int? MinLength { get => Target?.MinLength; } /// - public string Pattern { get => Target?.Pattern; } + public string? Pattern { get => Target?.Pattern; } /// public decimal? MultipleOf { get => Target?.MultipleOf; } /// - public JsonNode Default { get => Target?.Default; } + public JsonNode? Default { get => Target?.Default; } /// public bool ReadOnly { get => Target?.ReadOnly ?? false; } /// public bool WriteOnly { get => Target?.WriteOnly ?? false; } /// - public IList AllOf { get => Target?.AllOf; } + public IList? AllOf { get => Target?.AllOf; } /// - public IList OneOf { get => Target?.OneOf; } + public IList? OneOf { get => Target?.OneOf; } /// - public IList AnyOf { get => Target?.AnyOf; } + public IList? AnyOf { get => Target?.AnyOf; } /// - public IOpenApiSchema Not { get => Target?.Not; } + public IOpenApiSchema? Not { get => Target?.Not; } /// - public ISet Required { get => Target?.Required; } + public ISet? Required { get => Target?.Required; } /// - public IOpenApiSchema Items { get => Target?.Items; } + public IOpenApiSchema? Items { get => Target?.Items; } /// public int? MaxItems { get => Target?.MaxItems; } /// @@ -114,9 +108,9 @@ public string Description /// public bool? UniqueItems { get => Target?.UniqueItems; } /// - public IDictionary Properties { get => Target?.Properties; } + public IDictionary? Properties { get => Target?.Properties; } /// - public IDictionary PatternProperties { get => Target?.PatternProperties; } + public IDictionary? PatternProperties { get => Target?.PatternProperties; } /// public int? MaxProperties { get => Target?.MaxProperties; } /// @@ -124,34 +118,34 @@ public string Description /// public bool AdditionalPropertiesAllowed { get => Target?.AdditionalPropertiesAllowed ?? true; } /// - public IOpenApiSchema AdditionalProperties { get => Target?.AdditionalProperties; } + public IOpenApiSchema? AdditionalProperties { get => Target?.AdditionalProperties; } /// - public OpenApiDiscriminator Discriminator { get => Target?.Discriminator; } + public OpenApiDiscriminator? Discriminator { get => Target?.Discriminator; } /// - public JsonNode Example { get => Target?.Example; } + public JsonNode? Example { get => Target?.Example; } /// - public IList Examples { get => Target?.Examples; } + public IList? Examples { get => Target?.Examples; } /// - public IList Enum { get => Target?.Enum; } + public IList? Enum { get => Target?.Enum; } /// public bool UnevaluatedProperties { get => Target?.UnevaluatedProperties ?? false; } /// - public OpenApiExternalDocs ExternalDocs { get => Target?.ExternalDocs; } + public OpenApiExternalDocs? ExternalDocs { get => Target?.ExternalDocs; } /// public bool Deprecated { get => Target?.Deprecated ?? false; } /// - public OpenApiXml Xml { get => Target?.Xml; } + public OpenApiXml? Xml { get => Target?.Xml; } /// - public IDictionary Extensions { get => Target?.Extensions; } + public IDictionary? Extensions { get => Target?.Extensions; } /// - public IDictionary UnrecognizedKeywords { get => Target?.UnrecognizedKeywords; } + public IDictionary? UnrecognizedKeywords { get => Target?.UnrecognizedKeywords; } /// - public IDictionary Annotations { get => Target?.Annotations; } + public IDictionary? Annotations { get => Target?.Annotations; } /// - public IDictionary> DependentRequired { get => Target?.DependentRequired; } + public IDictionary>? DependentRequired { get => Target?.DependentRequired; } /// public override void SerializeAsV31(IOpenApiWriter writer) diff --git a/src/Microsoft.OpenApi/Models/References/OpenApiSecuritySchemeReference.cs b/src/Microsoft.OpenApi/Models/References/OpenApiSecuritySchemeReference.cs index 75ca30573..44741467b 100644 --- a/src/Microsoft.OpenApi/Models/References/OpenApiSecuritySchemeReference.cs +++ b/src/Microsoft.OpenApi/Models/References/OpenApiSecuritySchemeReference.cs @@ -19,7 +19,7 @@ public class OpenApiSecuritySchemeReference : BaseOpenApiReferenceHolderThe reference Id. /// The host OpenAPI document. /// The externally referenced file. - public OpenApiSecuritySchemeReference(string referenceId, OpenApiDocument hostDocument = null, string externalResource = null):base(referenceId, hostDocument, ReferenceType.SecurityScheme, externalResource) + public OpenApiSecuritySchemeReference(string referenceId, OpenApiDocument? hostDocument = null, string? externalResource = null):base(referenceId, hostDocument, ReferenceType.SecurityScheme, externalResource) { } /// @@ -32,38 +32,32 @@ private OpenApiSecuritySchemeReference(OpenApiSecuritySchemeReference openApiSec } /// - public string Description + public string? Description { - get => string.IsNullOrEmpty(Reference?.Description) ? Target?.Description : Reference.Description; - set - { - if (Reference is not null) - { - Reference.Description = value; - } - } + get => string.IsNullOrEmpty(Reference.Description) ? Target?.Description : Reference.Description; + set => Reference.Description = value; } /// - public string Name { get => Target?.Name; } + public string? Name { get => Target?.Name; } /// public ParameterLocation? In { get => Target?.In; } /// - public string Scheme { get => Target?.Scheme; } + public string? Scheme { get => Target?.Scheme; } /// - public string BearerFormat { get => Target?.BearerFormat; } + public string? BearerFormat { get => Target?.BearerFormat; } /// - public OpenApiOAuthFlows Flows { get => Target?.Flows; } + public OpenApiOAuthFlows? Flows { get => Target?.Flows; } /// - public Uri OpenIdConnectUrl { get => Target?.OpenIdConnectUrl; } + public Uri? OpenIdConnectUrl { get => Target?.OpenIdConnectUrl; } /// - public IDictionary Extensions { get => Target?.Extensions; } + public IDictionary? Extensions { get => Target?.Extensions; } /// public SecuritySchemeType? Type { get => Target?.Type; } diff --git a/src/Microsoft.OpenApi/Models/References/OpenApiTagReference.cs b/src/Microsoft.OpenApi/Models/References/OpenApiTagReference.cs index 031b5dbb1..59255a8b6 100644 --- a/src/Microsoft.OpenApi/Models/References/OpenApiTagReference.cs +++ b/src/Microsoft.OpenApi/Models/References/OpenApiTagReference.cs @@ -17,7 +17,7 @@ public class OpenApiTagReference : BaseOpenApiReferenceHolder /// Resolved target of the reference. /// - public override IOpenApiTag Target + public override IOpenApiTag? Target { get { @@ -35,7 +35,7 @@ public override IOpenApiTag Target /// 1. a absolute/relative file path, for example: ../commons/pet.json /// 2. a Url, for example: http://localhost/pet.json /// - public OpenApiTagReference(string referenceId, OpenApiDocument hostDocument = null, string externalResource = null):base(referenceId, hostDocument, ReferenceType.Tag, externalResource) + public OpenApiTagReference(string referenceId, OpenApiDocument? hostDocument = null, string? externalResource = null):base(referenceId, hostDocument, ReferenceType.Tag, externalResource) { } /// @@ -48,19 +48,19 @@ private OpenApiTagReference(OpenApiTagReference openApiTagReference):base(openAp } /// - public string Description + public string? Description { - get => string.IsNullOrEmpty(Reference?.Description) ? Target?.Description : Reference.Description; + get => string.IsNullOrEmpty(Reference.Description) ? Target?.Description : Reference.Description; } /// - public OpenApiExternalDocs ExternalDocs { get => Target?.ExternalDocs; } + public OpenApiExternalDocs? ExternalDocs { get => Target?.ExternalDocs; } /// - public IDictionary Extensions { get => Target?.Extensions; } + public IDictionary? Extensions { get => Target?.Extensions; } /// - public string Name { get => Target?.Name; } + public string? Name { get => Target?.Name; } /// public override IOpenApiTag CopyReferenceAsTargetElementWithOverrides(IOpenApiTag source) { diff --git a/src/Microsoft.OpenApi/Models/RuntimeExpressionAnyWrapper.cs b/src/Microsoft.OpenApi/Models/RuntimeExpressionAnyWrapper.cs index 35a08a422..d998ba400 100644 --- a/src/Microsoft.OpenApi/Models/RuntimeExpressionAnyWrapper.cs +++ b/src/Microsoft.OpenApi/Models/RuntimeExpressionAnyWrapper.cs @@ -14,8 +14,8 @@ namespace Microsoft.OpenApi.Models /// public class RuntimeExpressionAnyWrapper : IOpenApiElement { - private JsonNode _any; - private RuntimeExpression _expression; + private JsonNode? _any; + private RuntimeExpression? _expression; /// /// Parameterless constructor @@ -34,7 +34,7 @@ public RuntimeExpressionAnyWrapper(RuntimeExpressionAnyWrapper runtimeExpression /// /// Gets/Sets the /// - public JsonNode Any + public JsonNode? Any { get { @@ -50,7 +50,7 @@ public JsonNode Any /// /// Gets/Set the /// - public RuntimeExpression Expression + public RuntimeExpression? Expression { get { diff --git a/src/Microsoft.OpenApi/Reader/JsonNodeHelper.cs b/src/Microsoft.OpenApi/Reader/JsonNodeHelper.cs index e8dee12d1..b64c7ea43 100644 --- a/src/Microsoft.OpenApi/Reader/JsonNodeHelper.cs +++ b/src/Microsoft.OpenApi/Reader/JsonNodeHelper.cs @@ -10,7 +10,7 @@ namespace Microsoft.OpenApi.Reader { internal static class JsonNodeHelper { - public static string GetScalarValue(this JsonNode node) + public static string? GetScalarValue(this JsonNode node) { var scalarNode = node is JsonValue value ? value : throw new OpenApiException($"Expected scalar value."); diff --git a/src/Microsoft.OpenApi/Reader/OpenApiDiagnostic.cs b/src/Microsoft.OpenApi/Reader/OpenApiDiagnostic.cs index 5340d2aef..247bb2ba8 100644 --- a/src/Microsoft.OpenApi/Reader/OpenApiDiagnostic.cs +++ b/src/Microsoft.OpenApi/Reader/OpenApiDiagnostic.cs @@ -33,7 +33,7 @@ public class OpenApiDiagnostic : IDiagnostic /// /// The diagnostic instance of which the errors and warnings are to be appended to this diagnostic's /// The originating file of the diagnostic to be appended, this is prefixed to each error and warning to indicate the originating file - public void AppendDiagnostic(OpenApiDiagnostic diagnosticToAdd, string fileNameToAdd = null) + public void AppendDiagnostic(OpenApiDiagnostic diagnosticToAdd, string? fileNameToAdd = null) { var fileNameIsSupplied = !string.IsNullOrEmpty(fileNameToAdd); foreach (var err in diagnosticToAdd.Errors) diff --git a/src/Microsoft.OpenApi/Reader/OpenApiJsonReader.cs b/src/Microsoft.OpenApi/Reader/OpenApiJsonReader.cs index bac24a51d..87a56d90d 100644 --- a/src/Microsoft.OpenApi/Reader/OpenApiJsonReader.cs +++ b/src/Microsoft.OpenApi/Reader/OpenApiJsonReader.cs @@ -33,14 +33,14 @@ public ReadResult Read(MemoryStream input, if (input is null) throw new ArgumentNullException(nameof(input)); if (settings is null) throw new ArgumentNullException(nameof(settings)); - JsonNode jsonNode; + JsonNode? jsonNode; var diagnostic = new OpenApiDiagnostic(); settings ??= new OpenApiReaderSettings(); // Parse the JSON text in the stream into JsonNodes try { - jsonNode = JsonNode.Parse(input); + jsonNode = JsonNode.Parse(input) ?? throw new InvalidOperationException($"Cannot parse input stream, {nameof(input)}."); } catch (JsonException ex) { @@ -75,7 +75,7 @@ public ReadResult Read(JsonNode jsonNode, DefaultContentType = settings.DefaultContentType }; - OpenApiDocument document = null; + OpenApiDocument? document = null; try { // Parse the OpenAPI Document @@ -88,17 +88,20 @@ public ReadResult Read(JsonNode jsonNode, } // Validate the document - if (settings.RuleSet != null && settings.RuleSet.Rules.Any()) + if (document is not null && settings.RuleSet is not null && settings.RuleSet.Rules.Any()) { var openApiErrors = document.Validate(settings.RuleSet); - foreach (var item in openApiErrors.OfType()) - { - diagnostic.Errors.Add(item); - } - foreach (var item in openApiErrors.OfType()) + if(openApiErrors is not null) { - diagnostic.Warnings.Add(item); - } + foreach (var item in openApiErrors.OfType()) + { + diagnostic.Errors.Add(item); + } + foreach (var item in openApiErrors.OfType()) + { + diagnostic.Warnings.Add(item); + } + } } return new() @@ -122,13 +125,14 @@ public async Task ReadAsync(Stream input, if (input is null) throw new ArgumentNullException(nameof(input)); if (settings is null) throw new ArgumentNullException(nameof(settings)); - JsonNode jsonNode; + JsonNode? jsonNode; var diagnostic = new OpenApiDiagnostic(); // Parse the JSON text in the stream into JsonNodes try { - jsonNode = await JsonNode.ParseAsync(input, cancellationToken: cancellationToken).ConfigureAwait(false); + jsonNode = await JsonNode.ParseAsync(input, cancellationToken: cancellationToken).ConfigureAwait(false) ?? + throw new InvalidOperationException($"failed to parse input stream, {nameof(input)}"); } catch (JsonException ex) { @@ -144,11 +148,11 @@ public async Task ReadAsync(Stream input, } /// - public T ReadFragment(MemoryStream input, + public T? ReadFragment(MemoryStream input, OpenApiSpecVersion version, OpenApiDocument openApiDocument, out OpenApiDiagnostic diagnostic, - OpenApiReaderSettings settings = null) where T : IOpenApiElement + OpenApiReaderSettings? settings = null) where T : IOpenApiElement { Utils.CheckArgumentNull(input); Utils.CheckArgumentNull(openApiDocument); @@ -158,7 +162,7 @@ public T ReadFragment(MemoryStream input, // Parse the JSON try { - jsonNode = JsonNode.Parse(input); + jsonNode = JsonNode.Parse(input) ?? throw new InvalidOperationException($"Failed to parse stream, {nameof(input)}"); } catch (JsonException ex) { @@ -171,11 +175,11 @@ public T ReadFragment(MemoryStream input, } /// - public T ReadFragment(JsonNode input, - OpenApiSpecVersion version, - OpenApiDocument openApiDocument, - out OpenApiDiagnostic diagnostic, - OpenApiReaderSettings settings = null) where T : IOpenApiElement + public T? ReadFragment(JsonNode input, + OpenApiSpecVersion version, + OpenApiDocument openApiDocument, + out OpenApiDiagnostic diagnostic, + OpenApiReaderSettings? settings = null) where T : IOpenApiElement { diagnostic = new(); settings ??= new OpenApiReaderSettings(); @@ -184,7 +188,7 @@ public T ReadFragment(JsonNode input, ExtensionParsers = settings.ExtensionParsers }; - IOpenApiElement element = null; + IOpenApiElement? element = null; try { // Parse the OpenAPI element @@ -196,16 +200,19 @@ public T ReadFragment(JsonNode input, } // Validate the element - if (settings.RuleSet != null && settings.RuleSet.Rules.Any()) + if (element is not null && settings.RuleSet is not null && settings.RuleSet.Rules.Any()) { var errors = element.Validate(settings.RuleSet); - foreach (var item in errors) + if (errors is not null) { - diagnostic.Errors.Add(item); + foreach (var item in errors) + { + diagnostic.Errors.Add(item); + } } } - return (T)element; + return (T?)element; } } } diff --git a/src/Microsoft.OpenApi/Reader/OpenApiModelFactory.cs b/src/Microsoft.OpenApi/Reader/OpenApiModelFactory.cs index c30f16777..e370720e3 100644 --- a/src/Microsoft.OpenApi/Reader/OpenApiModelFactory.cs +++ b/src/Microsoft.OpenApi/Reader/OpenApiModelFactory.cs @@ -28,8 +28,8 @@ public static class OpenApiModelFactory /// The OpenAPI format. /// An OpenAPI document instance. public static ReadResult Load(MemoryStream stream, - string format = null, - OpenApiReaderSettings settings = null) + string? format = null, + OpenApiReaderSettings? settings = null) { #if NET6_0_OR_GREATER ArgumentNullException.ThrowIfNull(stream); @@ -62,7 +62,7 @@ public static ReadResult Load(MemoryStream stream, /// The OpenApiReader settings. /// Instance of newly created IOpenApiElement. /// The OpenAPI element. - public static T Load(MemoryStream input, OpenApiSpecVersion version, string format, OpenApiDocument openApiDocument, out OpenApiDiagnostic diagnostic, OpenApiReaderSettings settings = null) where T : IOpenApiElement + public static T? Load(MemoryStream input, OpenApiSpecVersion version, string? format, OpenApiDocument openApiDocument, out OpenApiDiagnostic diagnostic, OpenApiReaderSettings? settings = null) where T : IOpenApiElement { format ??= InspectStreamFormat(input); settings ??= DefaultReaderSettings.Value; @@ -76,7 +76,7 @@ public static T Load(MemoryStream input, OpenApiSpecVersion version, string f /// The OpenApi reader settings. /// The cancellation token /// - public static async Task LoadAsync(string url, OpenApiReaderSettings settings = null, CancellationToken token = default) + public static async Task LoadAsync(string url, OpenApiReaderSettings? settings = null, CancellationToken token = default) { settings ??= DefaultReaderSettings.Value; var (stream, format) = await RetrieveStreamAndFormatAsync(url, settings, token).ConfigureAwait(false); @@ -94,7 +94,7 @@ public static async Task LoadAsync(string url, OpenApiReaderSettings /// /// Instance of newly created IOpenApiElement. /// The OpenAPI element. - public static async Task LoadAsync(string url, OpenApiSpecVersion version, OpenApiDocument openApiDocument, OpenApiReaderSettings settings = null, CancellationToken token = default) where T : IOpenApiElement + public static async Task LoadAsync(string url, OpenApiSpecVersion version, OpenApiDocument openApiDocument, OpenApiReaderSettings? settings = null, CancellationToken token = default) where T : IOpenApiElement { settings ??= DefaultReaderSettings.Value; var (stream, format) = await RetrieveStreamAndFormatAsync(url, settings, token).ConfigureAwait(false); @@ -109,7 +109,7 @@ public static async Task LoadAsync(string url, OpenApiSpecVersion version, /// Propagates notification that operations should be cancelled. /// The Open API format /// - public static async Task LoadAsync(Stream input, string format = null, OpenApiReaderSettings settings = null, CancellationToken cancellationToken = default) + public static async Task LoadAsync(Stream input, string? format = null, OpenApiReaderSettings? settings = null, CancellationToken cancellationToken = default) { #if NET6_0_OR_GREATER ArgumentNullException.ThrowIfNull(input); @@ -155,11 +155,11 @@ public static async Task LoadAsync(Stream input, string format = nul /// /// /// - public static async Task LoadAsync(Stream input, + public static async Task LoadAsync(Stream input, OpenApiSpecVersion version, OpenApiDocument openApiDocument, - string format = null, - OpenApiReaderSettings settings = null, + string? format = null, + OpenApiReaderSettings? settings = null, CancellationToken token = default) where T : IOpenApiElement { Utils.CheckArgumentNull(openApiDocument); @@ -189,8 +189,8 @@ public static async Task LoadAsync(Stream input, /// The OpenApi reader settings. /// An OpenAPI document instance. public static ReadResult Parse(string input, - string format = null, - OpenApiReaderSettings settings = null) + string? format = null, + OpenApiReaderSettings? settings = null) { #if NET6_0_OR_GREATER ArgumentException.ThrowIfNullOrEmpty(input); @@ -216,12 +216,12 @@ public static ReadResult Parse(string input, /// The Open API format /// The OpenApi reader settings. /// An OpenAPI document instance. - public static T Parse(string input, + public static T? Parse(string input, OpenApiSpecVersion version, OpenApiDocument openApiDocument, out OpenApiDiagnostic diagnostic, - string format = null, - OpenApiReaderSettings settings = null) where T : IOpenApiElement + string? format = null, + OpenApiReaderSettings? settings = null) where T : IOpenApiElement { #if NET6_0_OR_GREATER ArgumentException.ThrowIfNullOrEmpty(input); @@ -248,22 +248,22 @@ private static async Task InternalLoadAsync(Stream input, string for // Merge diagnostics of external reference if (diagnosticExternalRefs != null) { - readResult.Diagnostic.Errors.AddRange(diagnosticExternalRefs.Errors); - readResult.Diagnostic.Warnings.AddRange(diagnosticExternalRefs.Warnings); + readResult.Diagnostic?.Errors.AddRange(diagnosticExternalRefs.Errors); + readResult.Diagnostic?.Warnings.AddRange(diagnosticExternalRefs.Warnings); } } return readResult; } - private static async Task LoadExternalRefsAsync(OpenApiDocument document, OpenApiReaderSettings settings, string format = null, CancellationToken token = default) + private static async Task LoadExternalRefsAsync(OpenApiDocument? document, OpenApiReaderSettings settings, string? format = null, CancellationToken token = default) { // Create workspace for all documents to live in. var baseUrl = settings.BaseUrl ?? new Uri(OpenApiConstants.BaseRegistryUri); var openApiWorkSpace = new OpenApiWorkspace(baseUrl); // Load this root document into the workspace - var streamLoader = new DefaultStreamLoader(settings.BaseUrl, settings.HttpClient); + var streamLoader = new DefaultStreamLoader(baseUrl, settings.HttpClient); var workspaceLoader = new OpenApiWorkspaceLoader(openApiWorkSpace, settings.CustomExternalLoader ?? streamLoader, settings); return await workspaceLoader.LoadAsync(new OpenApiReference() { ExternalResource = "/" }, document, format ?? OpenApiConstants.Json, null, token).ConfigureAwait(false); } @@ -285,21 +285,26 @@ private static ReadResult InternalLoad(MemoryStream input, string format, OpenAp return readResult; } - private static async Task<(Stream, string)> RetrieveStreamAndFormatAsync(string url, OpenApiReaderSettings settings, CancellationToken token = default) + private static async Task<(Stream, string?)> RetrieveStreamAndFormatAsync(string url, OpenApiReaderSettings settings, CancellationToken token = default) { - if (!string.IsNullOrEmpty(url)) + if (string.IsNullOrEmpty(url)) + { + throw new ArgumentException($"Parameter {nameof(url)} is null or empty. Please provide the correct path or URL to the file."); + } + else { Stream stream; - string format; + string? format; if (url.StartsWith("http", StringComparison.OrdinalIgnoreCase) || url.StartsWith("https", StringComparison.OrdinalIgnoreCase)) { var response = await settings.HttpClient.GetAsync(url, token).ConfigureAwait(false); - var mediaType = response.Content.Headers.ContentType.MediaType; - var contentType = mediaType.Split(";".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)[0]; - format = contentType.Split('/').Last().Split('+').Last().Split('-').Last(); - // for non-standard MIME types e.g. text/x-yaml used in older libs or apps + var mediaType = response.Content.Headers.ContentType?.MediaType; + var contentType = mediaType?.Split(";".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)[0]; + format = contentType?.Split('/').Last().Split('+').Last().Split('-').Last(); + + // for non-standard MIME types e.g. text/x-yaml used in older libs or apps #if NETSTANDARD2_0 stream = await response.Content.ReadAsStreamAsync(); #else @@ -332,7 +337,6 @@ SecurityException or return (stream, format); } } - return (null, null); } private static string InspectInputFormat(string input) @@ -367,7 +371,7 @@ private static string InspectStreamFormat(Stream stream) }; } - private static async Task<(Stream, string)> PrepareStreamForReadingAsync(Stream input, string format, CancellationToken token = default) + private static async Task<(Stream, string)> PrepareStreamForReadingAsync(Stream input, string? format, CancellationToken token = default) { Stream preparedStream = input; diff --git a/src/Microsoft.OpenApi/Reader/OpenApiReaderSettings.cs b/src/Microsoft.OpenApi/Reader/OpenApiReaderSettings.cs index 2d24947b8..6f15fa5f6 100644 --- a/src/Microsoft.OpenApi/Reader/OpenApiReaderSettings.cs +++ b/src/Microsoft.OpenApi/Reader/OpenApiReaderSettings.cs @@ -19,7 +19,7 @@ namespace Microsoft.OpenApi.Reader public class OpenApiReaderSettings { private static readonly Lazy httpClient = new(() => new HttpClient()); - private HttpClient _httpClient; + private HttpClient? _httpClient; /// /// HttpClient to use for making requests and retrieve documents /// @@ -107,7 +107,7 @@ public Dictionary Readers /// /// Dictionary of parsers for converting extensions into strongly typed classes /// - public Dictionary> ExtensionParsers { get; set; } = new(); + public Dictionary>? ExtensionParsers { get; set; } = new(); /// /// Rules to use for validating OpenAPI specification. If none are provided a default set of rules are applied. @@ -117,12 +117,12 @@ public Dictionary Readers /// /// URL where relative references should be resolved from if the description does not contain Server definitions /// - public Uri BaseUrl { get; set; } + public Uri? BaseUrl { get; set; } /// /// Allows clients to define a custom DefaultContentType if produces array is empty /// - public List DefaultContentType { get; set; } + public List? DefaultContentType { get; set; } /// /// Function used to provide an alternative loader for accessing external references. @@ -130,7 +130,7 @@ public Dictionary Readers /// /// Default loader will attempt to dereference http(s) urls and file urls. /// - public IStreamLoader CustomExternalLoader { get; set; } + public IStreamLoader? CustomExternalLoader { get; set; } /// /// Whether to leave the object open after reading @@ -157,12 +157,13 @@ public void AddMicrosoftExtensionParsers() TryAddExtensionParser(OpenApiReservedParameterExtension.Name, static (i, _ ) => OpenApiReservedParameterExtension.Parse(i)); TryAddExtensionParser(OpenApiEnumFlagsExtension.Name, static (i, _ ) => OpenApiEnumFlagsExtension.Parse(i)); } + private void TryAddExtensionParser(string name, Func parser) { #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP || NET5_0_OR_GREATER - ExtensionParsers.TryAdd(name, parser); + ExtensionParsers?.TryAdd(name, parser); #else - if (!ExtensionParsers.ContainsKey(name)) + if (ExtensionParsers is not null && !ExtensionParsers.ContainsKey(name)) ExtensionParsers.Add(name, parser); #endif } diff --git a/src/Microsoft.OpenApi/Reader/ParseNodes/AnyFieldMapParameter.cs b/src/Microsoft.OpenApi/Reader/ParseNodes/AnyFieldMapParameter.cs index 16456c400..7d37b3118 100644 --- a/src/Microsoft.OpenApi/Reader/ParseNodes/AnyFieldMapParameter.cs +++ b/src/Microsoft.OpenApi/Reader/ParseNodes/AnyFieldMapParameter.cs @@ -14,9 +14,9 @@ internal class AnyFieldMapParameter /// Constructor. /// public AnyFieldMapParameter( - Func propertyGetter, - Action propertySetter, - Func SchemaGetter = null) + Func propertyGetter, + Action propertySetter, + Func? SchemaGetter = null) { this.PropertyGetter = propertyGetter; this.PropertySetter = propertySetter; @@ -26,16 +26,16 @@ public AnyFieldMapParameter( /// /// Function to retrieve the value of the property. /// - public Func PropertyGetter { get; } + public Func PropertyGetter { get; } /// /// Function to set the value of the property. /// - public Action PropertySetter { get; } + public Action PropertySetter { get; } /// /// Function to get the schema to apply to the property. /// - public Func SchemaGetter { get; } + public Func? SchemaGetter { get; } } } diff --git a/src/Microsoft.OpenApi/Reader/ParseNodes/AnyListFieldMapParameter.cs b/src/Microsoft.OpenApi/Reader/ParseNodes/AnyListFieldMapParameter.cs index fc87a548e..873f0df15 100644 --- a/src/Microsoft.OpenApi/Reader/ParseNodes/AnyListFieldMapParameter.cs +++ b/src/Microsoft.OpenApi/Reader/ParseNodes/AnyListFieldMapParameter.cs @@ -16,7 +16,7 @@ internal class AnyListFieldMapParameter public AnyListFieldMapParameter( Func> propertyGetter, Action> propertySetter, - Func SchemaGetter = null) + Func? SchemaGetter = null) { this.PropertyGetter = propertyGetter; this.PropertySetter = propertySetter; @@ -36,6 +36,6 @@ public AnyListFieldMapParameter( /// /// Function to get the schema to apply to the property. /// - public Func SchemaGetter { get; } + public Func? SchemaGetter { get; } } } diff --git a/src/Microsoft.OpenApi/Reader/ParseNodes/AnyMapFieldMapParameter.cs b/src/Microsoft.OpenApi/Reader/ParseNodes/AnyMapFieldMapParameter.cs index 52397aed9..6a16f4e46 100644 --- a/src/Microsoft.OpenApi/Reader/ParseNodes/AnyMapFieldMapParameter.cs +++ b/src/Microsoft.OpenApi/Reader/ParseNodes/AnyMapFieldMapParameter.cs @@ -15,10 +15,10 @@ internal class AnyMapFieldMapParameter /// Constructor /// public AnyMapFieldMapParameter( - Func> propertyMapGetter, - Func propertyGetter, + Func?> propertyMapGetter, + Func propertyGetter, Action propertySetter, - Func schemaGetter) + Func schemaGetter) { this.PropertyMapGetter = propertyMapGetter; this.PropertyGetter = propertyGetter; @@ -29,12 +29,12 @@ public AnyMapFieldMapParameter( /// /// Function to retrieve the property that is a map from string to an inner element containing IOpenApiAny. /// - public Func> PropertyMapGetter { get; } + public Func?> PropertyMapGetter { get; } /// /// Function to retrieve the value of the property from an inner element. /// - public Func PropertyGetter { get; } + public Func PropertyGetter { get; } /// /// Function to set the value of the property. @@ -44,6 +44,6 @@ public AnyMapFieldMapParameter( /// /// Function to get the schema to apply to the property. /// - public Func SchemaGetter { get; } + public Func SchemaGetter { get; } } } diff --git a/src/Microsoft.OpenApi/Reader/ParseNodes/JsonPointerExtensions.cs b/src/Microsoft.OpenApi/Reader/ParseNodes/JsonPointerExtensions.cs index b349f2d5d..28c0a48fd 100644 --- a/src/Microsoft.OpenApi/Reader/ParseNodes/JsonPointerExtensions.cs +++ b/src/Microsoft.OpenApi/Reader/ParseNodes/JsonPointerExtensions.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System; @@ -14,7 +14,7 @@ public static class JsonPointerExtensions /// /// Finds the JSON node that corresponds to this JSON pointer based on the base Json node. /// - public static JsonNode Find(this JsonPointer currentPointer, JsonNode baseJsonNode) + public static JsonNode? Find(this JsonPointer currentPointer, JsonNode baseJsonNode) { if (currentPointer.Tokens.Length == 0) { diff --git a/src/Microsoft.OpenApi/Reader/ParseNodes/ListNode.cs b/src/Microsoft.OpenApi/Reader/ParseNodes/ListNode.cs index 96235271e..4f48cbb04 100644 --- a/src/Microsoft.OpenApi/Reader/ParseNodes/ListNode.cs +++ b/src/Microsoft.OpenApi/Reader/ParseNodes/ListNode.cs @@ -25,37 +25,40 @@ public override List CreateList(Func map, Ope { if (_nodeList == null) { - throw new OpenApiReaderException($"Expected list while parsing {typeof(T).Name}", _nodeList); + throw new OpenApiReaderException($"Expected list while parsing {typeof(T).Name}"); } - return _nodeList?.Select(n => map(new MapNode(Context, n as JsonObject), hostDocument)) + var list = _nodeList + .OfType() + .Select(n => map(new MapNode(Context, n), hostDocument)) .Where(i => i != null) .ToList(); + return list; } public override List CreateListOfAny() { - var list = _nodeList.Select(n => Create(Context, n).CreateAny()) + var list = _nodeList.OfType().Select(n => Create(Context, n).CreateAny()) .Where(i => i != null) .ToList(); return list; } - public override List CreateSimpleList(Func map, OpenApiDocument openApiDocument) + public override List CreateSimpleList(Func map, OpenApiDocument openApiDocument) { if (_nodeList == null) { - throw new OpenApiReaderException($"Expected list while parsing {typeof(T).Name}", _nodeList); + throw new OpenApiReaderException($"Expected list while parsing {typeof(T).Name}"); } - return _nodeList.Select(n => map(new(Context, n), openApiDocument)).ToList(); + return _nodeList.OfType().Select(n => map(new(Context, n), openApiDocument)).ToList(); } public IEnumerator GetEnumerator() { - return _nodeList.Select(n => Create(Context, n)).ToList().GetEnumerator(); + return _nodeList.OfType().Select(n => Create(Context, n)).ToList().GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() diff --git a/src/Microsoft.OpenApi/Reader/ParseNodes/MapNode.cs b/src/Microsoft.OpenApi/Reader/ParseNodes/MapNode.cs index 4988756d2..3d3ef71af 100644 --- a/src/Microsoft.OpenApi/Reader/ParseNodes/MapNode.cs +++ b/src/Microsoft.OpenApi/Reader/ParseNodes/MapNode.cs @@ -11,7 +11,6 @@ using System.Text.Json.Serialization; using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Exceptions; -using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; namespace Microsoft.OpenApi.Reader.ParseNodes @@ -33,14 +32,14 @@ public MapNode(ParsingContext context, JsonNode node) : base( } _node = mapNode; - _nodes = _node.Where(static p => p.Value is not null).Select(p => new PropertyNode(Context, p.Key, p.Value)).ToList(); + _nodes = _node.Where(p => p.Value is not null).OfType>().Select(p => new PropertyNode(Context, p.Key, p.Value)).ToList(); } - public PropertyNode this[string key] + public PropertyNode? this[string key] { get { - if (_node.TryGetPropertyValue(key, out var node)) + if (_node.TryGetPropertyValue(key, out var node) && node is not null) { return new(Context, key, node); } @@ -63,7 +62,7 @@ public override Dictionary CreateMap(Func CreateSimpleMap(Func map) return nodes.ToDictionary(k => k.key, v => v.value); } - public override Dictionary> CreateArrayMap(Func map, OpenApiDocument openApiDocument) + public override Dictionary> CreateArrayMap(Func map, OpenApiDocument? openApiDocument) { var jsonMap = _node ?? throw new OpenApiReaderException($"Expected map while parsing {typeof(T).Name}", Context); @@ -117,7 +116,7 @@ public override Dictionary> CreateArrayMap(Func values = new HashSet(arrayNode.Select(item => map(new ValueNode(Context, item), openApiDocument))); + ISet values = new HashSet(arrayNode.OfType().Select(item => map(new ValueNode(Context, item), openApiDocument))); return (key, values); @@ -147,52 +146,48 @@ public override string GetRaw() return x; } - public T GetReferencedObject(ReferenceType referenceType, string referenceId, string summary = null, string description = null) - where T : IOpenApiReferenceHolder, new() + public string? GetReferencePointer() { - return new() - { - Reference = Context.VersionService.ConvertToOpenApiReference(referenceId, referenceType, summary, description) - }; - } - - public string GetReferencePointer() - { - if (!_node.TryGetPropertyValue("$ref", out JsonNode refNode)) + if (!_node.TryGetPropertyValue("$ref", out JsonNode? refNode)) { return null; } - return refNode.GetScalarValue(); + return refNode?.GetScalarValue(); } - public string GetSummaryValue() + public string? GetSummaryValue() { - if (!_node.TryGetPropertyValue("summary", out JsonNode summaryNode)) + if (!_node.TryGetPropertyValue("summary", out JsonNode? summaryNode)) { return null; } - return summaryNode.GetScalarValue(); + return summaryNode?.GetScalarValue(); } - public string GetDescriptionValue() + public string? GetDescriptionValue() { - if (!_node.TryGetPropertyValue("description", out JsonNode descriptionNode)) + if (!_node.TryGetPropertyValue("description", out JsonNode? descriptionNode)) { return null; } - return descriptionNode.GetScalarValue(); + return descriptionNode?.GetScalarValue(); } - public string GetScalarValue(ValueNode key) + public string? GetScalarValue(ValueNode key) { - var scalarNode = _node[key.GetScalarValue()] is JsonValue jsonValue - ? jsonValue - : throw new OpenApiReaderException($"Expected scalar while parsing {key.GetScalarValue()}", Context); + var keyValue = key.GetScalarValue(); + if (keyValue is not null) + { + var scalarNode = _node[keyValue] is JsonValue jsonValue + ? jsonValue + : throw new OpenApiReaderException($"Expected scalar while parsing {key.GetScalarValue()}", Context); - return Convert.ToString(scalarNode?.GetValue(), CultureInfo.InvariantCulture); + return Convert.ToString(scalarNode?.GetValue(), CultureInfo.InvariantCulture); + } + return null; } /// diff --git a/src/Microsoft.OpenApi/Reader/ParseNodes/ParseNode.cs b/src/Microsoft.OpenApi/Reader/ParseNodes/ParseNode.cs index 798795350..699022193 100644 --- a/src/Microsoft.OpenApi/Reader/ParseNodes/ParseNode.cs +++ b/src/Microsoft.OpenApi/Reader/ParseNodes/ParseNode.cs @@ -43,7 +43,7 @@ public static ParseNode Create(ParsingContext context, JsonNode node) return new MapNode(context, mapNode); } - return new ValueNode(context, node as JsonValue); + return new ValueNode(context, node); } public virtual List CreateList(Func map, OpenApiDocument hostDocument) @@ -56,7 +56,7 @@ public virtual Dictionary CreateMap(Func CreateSimpleList(Func map, OpenApiDocument openApiDocument) + public virtual List CreateSimpleList(Func map, OpenApiDocument openApiDocument) { throw new OpenApiReaderException("Cannot create simple list from this type of node.", Context); } @@ -86,7 +86,7 @@ public virtual List CreateListOfAny() throw new OpenApiReaderException("Cannot create a list from this type of node.", Context); } - public virtual Dictionary> CreateArrayMap(Func map, OpenApiDocument openApiDocument) + public virtual Dictionary> CreateArrayMap(Func map, OpenApiDocument? openApiDocument) { throw new OpenApiReaderException("Cannot create array map from this type of node.", Context); } diff --git a/src/Microsoft.OpenApi/Reader/ParseNodes/RootNode.cs b/src/Microsoft.OpenApi/Reader/ParseNodes/RootNode.cs index b9e49b47d..741dccd2a 100644 --- a/src/Microsoft.OpenApi/Reader/ParseNodes/RootNode.cs +++ b/src/Microsoft.OpenApi/Reader/ParseNodes/RootNode.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System.Text.Json.Nodes; @@ -19,7 +19,7 @@ public RootNode( _jsonNode = jsonNode; } - public ParseNode Find(JsonPointer referencePointer) + public ParseNode? Find(JsonPointer referencePointer) { if (referencePointer.Find(_jsonNode) is not JsonNode jsonNode) { diff --git a/src/Microsoft.OpenApi/Reader/ParseNodes/ValueNode.cs b/src/Microsoft.OpenApi/Reader/ParseNodes/ValueNode.cs index f83d2ba66..fd45b2adf 100644 --- a/src/Microsoft.OpenApi/Reader/ParseNodes/ValueNode.cs +++ b/src/Microsoft.OpenApi/Reader/ParseNodes/ValueNode.cs @@ -4,6 +4,7 @@ using System; using System.Globalization; using System.Text.Json.Nodes; +using System.Xml.Linq; using Microsoft.OpenApi.Exceptions; namespace Microsoft.OpenApi.Reader.ParseNodes @@ -17,14 +18,16 @@ public ValueNode(ParsingContext context, JsonNode node) : base( { if (node is not JsonValue scalarNode) { - throw new OpenApiReaderException("Expected a value.", node); + throw new OpenApiReaderException($"Expected a value while parsing at {Context.GetLocation()}."); } _node = scalarNode; } public override string GetScalarValue() { - return Convert.ToString(_node.GetValue(), CultureInfo.InvariantCulture); + var scalarValue = _node.GetValue(); + return Convert.ToString(scalarValue, CultureInfo.InvariantCulture) + ?? throw new OpenApiReaderException($"Expected a value at {Context.GetLocation()}."); } /// diff --git a/src/Microsoft.OpenApi/Reader/ParsingContext.cs b/src/Microsoft.OpenApi/Reader/ParsingContext.cs index 485686e89..93d9517b9 100644 --- a/src/Microsoft.OpenApi/Reader/ParsingContext.cs +++ b/src/Microsoft.OpenApi/Reader/ParsingContext.cs @@ -28,21 +28,21 @@ public class ParsingContext /// /// Extension parsers /// - public Dictionary> ExtensionParsers { get; set; } = + public Dictionary>? ExtensionParsers { get; set; } = new(); - internal RootNode RootNode { get; set; } + internal RootNode? RootNode { get; set; } internal List Tags { get; private set; } = new(); /// /// The base url for the document /// - public Uri BaseUrl { get; set; } + public Uri? BaseUrl { get; set; } /// /// Default content type for a response object /// - public List DefaultContentType { get; set; } + public List? DefaultContentType { get; set; } /// /// Diagnostic object that returns metadata about the parsing process. @@ -106,7 +106,7 @@ public OpenApiDocument Parse(JsonNode jsonNode) /// OpenAPI version of the fragment /// The OpenApiDocument object to which the fragment belongs, used to lookup references. /// An OpenApiDocument populated based on the passed yamlDocument - public T ParseFragment(JsonNode jsonNode, OpenApiSpecVersion version, OpenApiDocument openApiDocument) where T : IOpenApiElement + public T? ParseFragment(JsonNode jsonNode, OpenApiSpecVersion version, OpenApiDocument openApiDocument) where T : IOpenApiElement { var node = ParseNode.Create(this, jsonNode); @@ -139,20 +139,20 @@ private static string GetVersion(RootNode rootNode) { var versionNode = rootNode.Find(new("/openapi")); - if (versionNode != null) + if (versionNode is not null) { return versionNode.GetScalarValue().Replace("\"", string.Empty); } versionNode = rootNode.Find(new("/swagger")); - return versionNode?.GetScalarValue().Replace("\"", string.Empty); + return versionNode?.GetScalarValue().Replace("\"", string.Empty) ?? throw new OpenApiException("Version node not found."); } /// /// Service providing all Version specific conversion functions /// - internal IOpenApiVersionService VersionService { get; set; } + internal IOpenApiVersionService? VersionService { get; set; } /// /// End the current object. @@ -173,9 +173,9 @@ public string GetLocation() /// /// Gets the value from the temporary storage matching the given key. /// - public T GetFromTempStorage(string key, object scope = null) + public T? GetFromTempStorage(string key, object? scope = null) { - Dictionary storage; + Dictionary? storage; if (scope == null) { @@ -192,9 +192,9 @@ public T GetFromTempStorage(string key, object scope = null) /// /// Sets the temporary storage for this key and value. /// - public void SetTempStorage(string key, object value, object scope = null) + public void SetTempStorage(string key, object? value, object? scope = null) { - Dictionary storage; + Dictionary? storage; if (scope == null) { @@ -271,7 +271,7 @@ public void PopLoop(string loopid) private void ValidateRequiredFields(OpenApiDocument doc, string version) { - if ((version.is2_0() || version.is3_0()) && (doc.Paths == null)) + if ((version.is2_0() || version.is3_0()) && (doc.Paths == null) && RootNode is not null) { // paths is a required field in OpenAPI 2.0 and 3.0 but optional in 3.1 RootNode.Context.Diagnostic.Errors.Add(new OpenApiError("", $"Paths is a REQUIRED field at {RootNode.Context.GetLocation()}")); diff --git a/src/Microsoft.OpenApi/Reader/ReadResult.cs b/src/Microsoft.OpenApi/Reader/ReadResult.cs index b7d3df12a..18847ad82 100644 --- a/src/Microsoft.OpenApi/Reader/ReadResult.cs +++ b/src/Microsoft.OpenApi/Reader/ReadResult.cs @@ -12,15 +12,15 @@ public class ReadResult /// /// The parsed OpenApiDocument. Null will be returned if the document could not be parsed. /// - public OpenApiDocument Document { get; set; } + public OpenApiDocument? Document { get; set; } /// /// OpenApiDiagnostic contains the Errors reported while parsing /// - public OpenApiDiagnostic Diagnostic { get; set; } + public OpenApiDiagnostic? Diagnostic { get; set; } /// /// Deconstructs the result for easier assignment on the client application. /// - public void Deconstruct(out OpenApiDocument document, out OpenApiDiagnostic diagnostic) + public void Deconstruct(out OpenApiDocument? document, out OpenApiDiagnostic? diagnostic) { document = Document; diagnostic = Diagnostic; diff --git a/src/Microsoft.OpenApi/Reader/Services/OpenApiRemoteReferenceCollector.cs b/src/Microsoft.OpenApi/Reader/Services/OpenApiRemoteReferenceCollector.cs index 8690735b8..c95955609 100644 --- a/src/Microsoft.OpenApi/Reader/Services/OpenApiRemoteReferenceCollector.cs +++ b/src/Microsoft.OpenApi/Reader/Services/OpenApiRemoteReferenceCollector.cs @@ -35,12 +35,12 @@ public override void Visit(IOpenApiReferenceHolder referenceHolder) /// /// Collect external references /// - private void AddExternalReferences(OpenApiReference reference) + private void AddExternalReferences(OpenApiReference? reference) { - if (reference is {IsExternal: true} && - !_references.ContainsKey(reference.ExternalResource)) + if (reference is {IsExternal: true} && reference.ExternalResource is {} externalResource&& + !_references.ContainsKey(externalResource)) { - _references.Add(reference.ExternalResource, reference); + _references.Add(externalResource, reference); } } } diff --git a/src/Microsoft.OpenApi/Reader/Services/OpenApiWorkspaceLoader.cs b/src/Microsoft.OpenApi/Reader/Services/OpenApiWorkspaceLoader.cs index 32090231f..75dd43512 100644 --- a/src/Microsoft.OpenApi/Reader/Services/OpenApiWorkspaceLoader.cs +++ b/src/Microsoft.OpenApi/Reader/Services/OpenApiWorkspaceLoader.cs @@ -21,16 +21,19 @@ public OpenApiWorkspaceLoader(OpenApiWorkspace workspace, IStreamLoader loader, } internal async Task LoadAsync(OpenApiReference reference, - OpenApiDocument document, - string format = null, - OpenApiDiagnostic diagnostic = null, + OpenApiDocument? document, + string? format = null, + OpenApiDiagnostic? diagnostic = null, CancellationToken cancellationToken = default) { - _workspace.AddDocumentId(reference.ExternalResource, document.BaseUri); + _workspace.AddDocumentId(reference.ExternalResource, document?.BaseUri); var version = diagnostic?.SpecificationVersion ?? OpenApiSpecVersion.OpenApi3_0; - _workspace.RegisterComponents(document); - document.Workspace = _workspace; - + if (document is not null) + { + _workspace.RegisterComponents(document); + document.Workspace = _workspace; + } + // Collect remote references by walking document var referenceCollector = new OpenApiRemoteReferenceCollector(); var collectorWalker = new OpenApiWalker(referenceCollector); @@ -43,7 +46,7 @@ internal async Task LoadAsync(OpenApiReference reference, { // If not already in workspace, load it and process references - if (!_workspace.Contains(item.ExternalResource)) + if (item.ExternalResource is not null && !_workspace.Contains(item.ExternalResource)) { var input = await _loader.LoadAsync(new(item.ExternalResource, UriKind.RelativeOrAbsolute), cancellationToken).ConfigureAwait(false); var result = await OpenApiDocument.LoadAsync(input, format, _readerSettings, cancellationToken).ConfigureAwait(false); diff --git a/src/Microsoft.OpenApi/Reader/V2/OpenApiContactDeserializer.cs b/src/Microsoft.OpenApi/Reader/V2/OpenApiContactDeserializer.cs index 00bfc2d74..9e4dcb2a9 100644 --- a/src/Microsoft.OpenApi/Reader/V2/OpenApiContactDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V2/OpenApiContactDeserializer.cs @@ -22,7 +22,14 @@ internal static partial class OpenApiV2Deserializer }, { "url", - (o, n, t) => o.Url = new(n.GetScalarValue(), UriKind.RelativeOrAbsolute) + (o, n, t) => + { + var url = n.GetScalarValue(); + if (url != null) + { + o.Url = new(url, UriKind.RelativeOrAbsolute); + } + } }, { "email", @@ -40,7 +47,7 @@ public static OpenApiContact LoadContact(ParseNode node, OpenApiDocument hostDoc var mapNode = node as MapNode; var contact = new OpenApiContact(); - ParseMap(mapNode, contact, _contactFixedFields, _contactPatternFields); + ParseMap(mapNode, contact, _contactFixedFields, _contactPatternFields, doc: hostDocument); return contact; } diff --git a/src/Microsoft.OpenApi/Reader/V2/OpenApiDocumentDeserializer.cs b/src/Microsoft.OpenApi/Reader/V2/OpenApiDocumentDeserializer.cs index da4060721..f7cbe711a 100644 --- a/src/Microsoft.OpenApi/Reader/V2/OpenApiDocumentDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V2/OpenApiDocumentDeserializer.cs @@ -70,15 +70,18 @@ internal static partial class OpenApiV2Deserializer { o.Components ??= new(); - o.Components.Parameters = n.CreateMap(LoadParameter, o); - - o.Components.RequestBodies = n.CreateMap((p, d) => - { - var parameter = LoadParameter(node: p, loadRequestBody: true, hostDocument: d); - return parameter != null ? CreateRequestBody(p.Context, parameter) : null; - }, - doc - ); + o.Components.Parameters = n.CreateMap(LoadParameter, o) + .Where(kvp => kvp.Value != null) + .ToDictionary(kvp => kvp.Key, kvp => kvp.Value!); + + o.Components.RequestBodies = n.CreateMap((p, d) => + { + var parameter = LoadParameter(node: p, loadRequestBody: true, hostDocument: d); + return parameter != null ? CreateRequestBody(p.Context, parameter) : null; + }, + doc + ).Where(kvp => kvp.Value != null) + .ToDictionary(kvp => kvp.Key, kvp => kvp.Value!); } }, { @@ -179,14 +182,14 @@ private static void MakeServers(IList servers, ParsingContext con { // Server Urls are always appended to Paths and Paths must start with / // so removing the slash prevents a double slash. - if (server.Url.EndsWith("/")) + if (server.Url is not null && server.Url.EndsWith("/")) { server.Url = server.Url.Substring(0, server.Url.Length - 1); } } } - private static string BuildUrl(string scheme, string host, string basePath) + private static string BuildUrl(string? scheme, string? host, string? basePath) { if (string.IsNullOrEmpty(scheme) && !string.IsNullOrEmpty(host)) { @@ -198,12 +201,15 @@ private static string BuildUrl(string scheme, string host, string basePath) #if NETSTANDARD2_1_OR_GREATER if (!String.IsNullOrEmpty(host) && host.Contains(':', StringComparison.OrdinalIgnoreCase)) #else - if (!String.IsNullOrEmpty(host) && host.Contains(':')) + if (!string.IsNullOrEmpty(host) && host is not null && host.Contains(':')) #endif { var pieces = host.Split(':'); - host = pieces.First(); - port = int.Parse(pieces.Last(), CultureInfo.InvariantCulture); + if (pieces is not null) + { + host = pieces[0]; + port = int.Parse(pieces[pieces.Count() -1], CultureInfo.InvariantCulture); + } } var uriBuilder = new UriBuilder @@ -227,7 +233,7 @@ public static OpenApiDocument LoadOpenApi(RootNode rootNode) var openApiNode = rootNode.GetMap(); - ParseMap(openApiNode, openApiDoc, _openApiFixedFields, _openApiPatternFields); + ParseMap(openApiNode, openApiDoc, _openApiFixedFields, _openApiPatternFields, doc: openApiDoc); if (openApiDoc.Paths != null) { @@ -252,12 +258,12 @@ public static OpenApiDocument LoadOpenApi(RootNode rootNode) FixRequestBodyReferences(openApiDoc); // Register components - openApiDoc.Workspace.RegisterComponents(openApiDoc); + openApiDoc.Workspace?.RegisterComponents(openApiDoc); return openApiDoc; } - private static void ProcessResponsesMediaTypes(MapNode mapNode, IEnumerable responses, ParsingContext context) + private static void ProcessResponsesMediaTypes(MapNode mapNode, IEnumerable? responses, ParsingContext context) { if (responses != null) { @@ -280,9 +286,9 @@ private static void FixRequestBodyReferences(OpenApiDocument doc) { // Walk all unresolved parameter references // if id matches with request body Id, change type - if (doc.Components?.RequestBodies is {Count: > 0}) + if (doc.Components?.RequestBodies is { Count: > 0 }) { - var fixer = new RequestBodyReferenceFixer(doc.Components?.RequestBodies); + var fixer = new RequestBodyReferenceFixer(doc.Components.RequestBodies); var walker = new OpenApiWalker(fixer); walker.Walk(doc); } @@ -312,14 +318,15 @@ public RequestBodyReferenceFixer(IDictionary reques public override void Visit(OpenApiOperation operation) { - var body = operation.Parameters.OfType().FirstOrDefault( + var body = operation.Parameters?.OfType().FirstOrDefault( p => p.UnresolvedReference + && p.Reference?.Id != null && _requestBodies.ContainsKey(p.Reference.Id)); - - if (body != null) + var id = body?.Reference?.Id; + if (body != null && !string.IsNullOrEmpty(id) && id is not null) { - operation.Parameters.Remove(body); - operation.RequestBody = new OpenApiRequestBodyReference(body.Reference.Id, body.Reference.HostDocument); + operation.Parameters?.Remove(body); + operation.RequestBody = new OpenApiRequestBodyReference(id, body.Reference?.HostDocument); } } } diff --git a/src/Microsoft.OpenApi/Reader/V2/OpenApiExternalDocsDeserializer.cs b/src/Microsoft.OpenApi/Reader/V2/OpenApiExternalDocsDeserializer.cs index 312313585..e63e42f1b 100644 --- a/src/Microsoft.OpenApi/Reader/V2/OpenApiExternalDocsDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V2/OpenApiExternalDocsDeserializer.cs @@ -19,11 +19,25 @@ internal static partial class OpenApiV2Deserializer { { OpenApiConstants.Description, - (o, n, _) => o.Description = n.GetScalarValue() + (o, n, _) => + { + var description = n.GetScalarValue(); + if (description != null) + { + o.Description = n.GetScalarValue(); + } + } }, { OpenApiConstants.Url, - (o, n, _) => o.Url = new(n.GetScalarValue(), UriKind.RelativeOrAbsolute) + (o, n, _) => + { + var url = n.GetScalarValue(); + if (url != null) + { + o.Url = new(url, UriKind.RelativeOrAbsolute); + } + } }, }; @@ -39,7 +53,7 @@ public static OpenApiExternalDocs LoadExternalDocs(ParseNode node, OpenApiDocume var externalDocs = new OpenApiExternalDocs(); - ParseMap(mapNode, externalDocs, _externalDocsFixedFields, _externalDocsPatternFields); + ParseMap(mapNode, externalDocs, _externalDocsFixedFields, _externalDocsPatternFields, doc: hostDocument); return externalDocs; } diff --git a/src/Microsoft.OpenApi/Reader/V2/OpenApiHeaderDeserializer.cs b/src/Microsoft.OpenApi/Reader/V2/OpenApiHeaderDeserializer.cs index e92c47231..4c156c2cc 100644 --- a/src/Microsoft.OpenApi/Reader/V2/OpenApiHeaderDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V2/OpenApiHeaderDeserializer.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System; @@ -25,7 +25,14 @@ internal static partial class OpenApiV2Deserializer }, { "type", - (o, n, _) => GetOrCreateSchema(o).Type = n.GetScalarValue().ToJsonSchemaType() + (o, n, _) => + { + var type = n.GetScalarValue(); + if (type != null) + { + GetOrCreateSchema(o).Type = type.ToJsonSchemaType(); + } + } }, { "format", @@ -37,7 +44,14 @@ internal static partial class OpenApiV2Deserializer }, { "collectionFormat", - (o, n, _) => LoadStyle(o, n.GetScalarValue()) + (o, n, _) => + { + var collectionFormat = n.GetScalarValue(); + if (collectionFormat != null) + { + LoadStyle(o, collectionFormat); + } + } }, { "default", @@ -45,7 +59,14 @@ internal static partial class OpenApiV2Deserializer }, { "maximum", - (o, n, _) => GetOrCreateSchema(o).Maximum = ParserHelper.ParseDecimalWithFallbackOnOverflow(n.GetScalarValue(), decimal.MaxValue) + (o, n, _) => + { + var max = n.GetScalarValue(); + if (max != null) + { + GetOrCreateSchema(o).Maximum = ParserHelper.ParseDecimalWithFallbackOnOverflow(max, decimal.MaxValue); + } + } }, { "exclusiveMaximum", @@ -53,7 +74,14 @@ internal static partial class OpenApiV2Deserializer }, { "minimum", - (o, n, _) => GetOrCreateSchema(o).Minimum = ParserHelper.ParseDecimalWithFallbackOnOverflow(n.GetScalarValue(), decimal.MinValue) + (o, n, _) => + { + var min = n.GetScalarValue(); + if (min != null) + { + GetOrCreateSchema(o).Minimum = ParserHelper.ParseDecimalWithFallbackOnOverflow(min, decimal.MinValue); + } + } }, { "exclusiveMinimum", @@ -61,11 +89,25 @@ internal static partial class OpenApiV2Deserializer }, { "maxLength", - (o, n, _) => GetOrCreateSchema(o).MaxLength = int.Parse(n.GetScalarValue(), CultureInfo.InvariantCulture) + (o, n, _) => + { + var maxLength = n.GetScalarValue(); + if (maxLength != null) + { + GetOrCreateSchema(o).MaxLength = int.Parse(maxLength, CultureInfo.InvariantCulture); + } + } }, { "minLength", - (o, n, _) => GetOrCreateSchema(o).MinLength = int.Parse(n.GetScalarValue(), CultureInfo.InvariantCulture) + (o, n, _) => + { + var minLength = n.GetScalarValue(); + if (minLength != null) + { + GetOrCreateSchema(o).MinLength = int.Parse(minLength, CultureInfo.InvariantCulture); + } + } }, { "pattern", @@ -73,19 +115,47 @@ internal static partial class OpenApiV2Deserializer }, { "maxItems", - (o, n, _) => GetOrCreateSchema(o).MaxItems = int.Parse(n.GetScalarValue(), CultureInfo.InvariantCulture) + (o, n, _) => + { + var maxItems = n.GetScalarValue(); + if (maxItems != null) + { + GetOrCreateSchema(o).MaxItems = int.Parse(maxItems, CultureInfo.InvariantCulture); + } + } }, { "minItems", - (o, n, _) => GetOrCreateSchema(o).MinItems = int.Parse(n.GetScalarValue(), CultureInfo.InvariantCulture) + (o, n, _) => + { + var minItems = n.GetScalarValue(); + if (minItems != null) + { + GetOrCreateSchema(o).MinItems = int.Parse(minItems, CultureInfo.InvariantCulture); + } + } }, { "uniqueItems", - (o, n, _) => GetOrCreateSchema(o).UniqueItems = bool.Parse(n.GetScalarValue()) + (o, n, _) => + { + var uniqueItems = n.GetScalarValue(); + if (uniqueItems != null) + { + GetOrCreateSchema(o).UniqueItems = bool.Parse(uniqueItems); + } + } }, { "multipleOf", - (o, n, _) => GetOrCreateSchema(o).MultipleOf = decimal.Parse(n.GetScalarValue(), CultureInfo.InvariantCulture) + (o, n, _) => + { + var multipleOf = n.GetScalarValue(); + if (multipleOf != null) + { + GetOrCreateSchema(o).MultipleOf = decimal.Parse(multipleOf, CultureInfo.InvariantCulture); + } + } }, { "enum", diff --git a/src/Microsoft.OpenApi/Reader/V2/OpenApiInfoDeserializer.cs b/src/Microsoft.OpenApi/Reader/V2/OpenApiInfoDeserializer.cs index 0d33e896c..7b5f850ee 100644 --- a/src/Microsoft.OpenApi/Reader/V2/OpenApiInfoDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V2/OpenApiInfoDeserializer.cs @@ -26,7 +26,14 @@ internal static partial class OpenApiV2Deserializer }, { "termsOfService", - (o, n, _) => o.TermsOfService = new(n.GetScalarValue(), UriKind.RelativeOrAbsolute) + (o, n, _) => + { + var terms = n.GetScalarValue(); + if (terms != null) + { + o.TermsOfService = new(terms, UriKind.RelativeOrAbsolute); + } + } }, { "contact", @@ -53,7 +60,7 @@ public static OpenApiInfo LoadInfo(ParseNode node, OpenApiDocument hostDocument) var info = new OpenApiInfo(); - ParseMap(mapNode, info, _infoFixedFields, _infoPatternFields); + ParseMap(mapNode, info, _infoFixedFields, _infoPatternFields, doc: hostDocument); return info; } diff --git a/src/Microsoft.OpenApi/Reader/V2/OpenApiLicenseDeserializer.cs b/src/Microsoft.OpenApi/Reader/V2/OpenApiLicenseDeserializer.cs index d4a95de89..c717f7a67 100644 --- a/src/Microsoft.OpenApi/Reader/V2/OpenApiLicenseDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V2/OpenApiLicenseDeserializer.cs @@ -22,7 +22,14 @@ internal static partial class OpenApiV2Deserializer }, { "url", - (o, n, _) => o.Url = new(n.GetScalarValue(), UriKind.RelativeOrAbsolute) + (o, n, _) => + { + var url = n.GetScalarValue(); + if (url != null) + { + o.Url = new(url, UriKind.RelativeOrAbsolute); + } + } }, }; diff --git a/src/Microsoft.OpenApi/Reader/V2/OpenApiOperationDeserializer.cs b/src/Microsoft.OpenApi/Reader/V2/OpenApiOperationDeserializer.cs index c2f6ca204..207845c7f 100644 --- a/src/Microsoft.OpenApi/Reader/V2/OpenApiOperationDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V2/OpenApiOperationDeserializer.cs @@ -49,6 +49,8 @@ internal static partial class OpenApiV2Deserializer { "parameters", (o, n, t) => o.Parameters = n.CreateList(LoadParameter, t) + .OfType() + .ToList() }, { "consumes", (_, n, doc) => { @@ -72,7 +74,14 @@ internal static partial class OpenApiV2Deserializer }, { "deprecated", - (o, n, _) => o.Deprecated = bool.Parse(n.GetScalarValue()) + (o, n, _) => + { + var deprecated = n.GetScalarValue(); + if (deprecated != null) + { + o.Deprecated = bool.Parse(deprecated); + } + } }, { "security", @@ -124,10 +133,14 @@ internal static OpenApiOperation LoadOperation(ParseNode node, OpenApiDocument h } } - foreach (var response in operation.Responses.Values.OfType()) + var responses = operation.Responses; + if (responses is not null) { - ProcessProduces(node.CheckMapNode("responses"), response, node.Context); - } + foreach (var response in responses.Values.OfType()) + { + ProcessProduces(node.CheckMapNode("responses"), response, node.Context); + } + } // Reset so that it's not picked up later node.Context.SetTempStorage(TempStorageKeys.OperationProduces, null); @@ -141,7 +154,7 @@ public static OpenApiResponses LoadResponses(ParseNode node, OpenApiDocument hos var domainObject = new OpenApiResponses(); - ParseMap(mapNode, domainObject, _responsesFixedFields, _responsesPatternFields, doc:hostDocument); + ParseMap(mapNode, domainObject, _responsesFixedFields, _responsesPatternFields, doc: hostDocument); return domainObject; } @@ -152,11 +165,13 @@ private static OpenApiRequestBody CreateFormBody(ParsingContext context, List k.Name, - v => + Properties = formParameters + .Where(p => p.Name != null) + .ToDictionary( + k => k.Name!, + v => { - var schema = v.Schema.CreateShallowCopy(); + var schema = v.Schema!.CreateShallowCopy(); schema.Description = v.Description; if (schema is OpenApiSchema openApiSchema) { @@ -164,7 +179,7 @@ private static OpenApiRequestBody CreateFormBody(ParsingContext context, List(formParameters.Where(static p => p.Required).Select(static p => p.Name), StringComparer.Ordinal) + Required = new HashSet(formParameters.Where(static p => p.Required && p.Name is not null).Select(static p => p.Name!), StringComparer.Ordinal) } }; @@ -179,8 +194,14 @@ private static OpenApiRequestBody CreateFormBody(ParsingContext context, List mediaType) }; - foreach (var value in formBody.Content.Values.Where(static x => x.Schema is not null && x.Schema.Properties.Any() && x.Schema.Type == null).Select(static x => x.Schema).OfType()) + foreach (var value in formBody.Content.Values + .Where(static x => x.Schema is not null + && x.Schema.Properties is not null + && x.Schema.Properties.Any() + && x.Schema.Type == null).Select(static x => x.Schema).OfType()) + { value.Type = JsonSchemaType.Object; + } return formBody; } @@ -207,12 +228,15 @@ internal static IOpenApiRequestBody CreateRequestBody( Extensions = bodyParameter.Extensions }; - requestBody.Extensions[OpenApiConstants.BodyName] = new OpenApiAny(bodyParameter.Name); + if (requestBody.Extensions is not null && bodyParameter.Name is not null) + { + requestBody.Extensions[OpenApiConstants.BodyName] = new OpenApiAny(bodyParameter.Name); + } return requestBody; } private static OpenApiTagReference LoadTagByReference( - string tagName, OpenApiDocument hostDocument) + string tagName, OpenApiDocument? hostDocument) { return new OpenApiTagReference(tagName, hostDocument); } diff --git a/src/Microsoft.OpenApi/Reader/V2/OpenApiParameterDeserializer.cs b/src/Microsoft.OpenApi/Reader/V2/OpenApiParameterDeserializer.cs index 267ba24d7..61f3b49b1 100644 --- a/src/Microsoft.OpenApi/Reader/V2/OpenApiParameterDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V2/OpenApiParameterDeserializer.cs @@ -35,19 +35,47 @@ internal static partial class OpenApiV2Deserializer }, { "required", - (o, n, t) => o.Required = bool.Parse(n.GetScalarValue()) + (o, n, t) => + { + var required = n.GetScalarValue(); + if (required != null) + { + o.Required = bool.Parse(required); + } + } }, { "deprecated", - (o, n, t) => o.Deprecated = bool.Parse(n.GetScalarValue()) + (o, n, t) => + { + var deprecated = n.GetScalarValue(); + if (deprecated != null) + { + o.Deprecated = bool.Parse(deprecated); + } + } }, { "allowEmptyValue", - (o, n, t) => o.AllowEmptyValue = bool.Parse(n.GetScalarValue()) + (o, n, t) => + { + var allowEmptyValue = n.GetScalarValue(); + if (allowEmptyValue != null) + { + o.AllowEmptyValue = bool.Parse(allowEmptyValue); + } + } }, { "type", - (o, n, t) => GetOrCreateSchema(o).Type = n.GetScalarValue().ToJsonSchemaType() + (o, n, t) => + { + var type = n.GetScalarValue(); + if (type != null) + { + GetOrCreateSchema(o).Type = type.ToJsonSchemaType(); + } + } }, { "items", @@ -55,7 +83,14 @@ internal static partial class OpenApiV2Deserializer }, { "collectionFormat", - (o, n, t) => LoadStyle(o, n.GetScalarValue()) + (o, n, t) => + { + var collectionFormat = n.GetScalarValue(); + if (collectionFormat != null) + { + LoadStyle(o, collectionFormat); + } + } }, { "format", @@ -63,23 +98,58 @@ internal static partial class OpenApiV2Deserializer }, { "minimum", - (o, n, t) => GetOrCreateSchema(o).Minimum = ParserHelper.ParseDecimalWithFallbackOnOverflow(n.GetScalarValue(), decimal.MinValue) + (o, n, t) => + { + var min = n.GetScalarValue(); + if (min != null) + { + GetOrCreateSchema(o).Minimum = ParserHelper.ParseDecimalWithFallbackOnOverflow(min, decimal.MinValue); + } + } }, { "maximum", - (o, n, t) => GetOrCreateSchema(o).Maximum = ParserHelper.ParseDecimalWithFallbackOnOverflow(n.GetScalarValue(), decimal.MaxValue) + (o, n, t) => + { + var max = n.GetScalarValue(); + if (max != null) + { + GetOrCreateSchema(o).Maximum = ParserHelper.ParseDecimalWithFallbackOnOverflow(max, decimal.MaxValue); + } + } }, { "maxLength", - (o, n, t) => GetOrCreateSchema(o).MaxLength = int.Parse(n.GetScalarValue(), CultureInfo.InvariantCulture) + (o, n, t) => + { + var maxLength = n.GetScalarValue(); + if (maxLength != null) + { + GetOrCreateSchema(o).MaxLength = int.Parse(maxLength, CultureInfo.InvariantCulture); + } + } }, { "minLength", - (o, n, t) => GetOrCreateSchema(o).MinLength = int.Parse(n.GetScalarValue(), CultureInfo.InvariantCulture) + (o, n, t) => + { + var minLength = n.GetScalarValue(); + if (minLength != null) + { + GetOrCreateSchema(o).MinLength = int.Parse(minLength, CultureInfo.InvariantCulture); + } + } }, { "readOnly", - (o, n, t) => GetOrCreateSchema(o).ReadOnly = bool.Parse(n.GetScalarValue()) + (o, n, t) => + { + var readOnly = n.GetScalarValue(); + if (readOnly != null) + { + GetOrCreateSchema(o).ReadOnly = bool.Parse(readOnly); + } + } }, { "default", @@ -139,7 +209,7 @@ private static void LoadStyle(OpenApiParameter p, string v) } } - private static void LoadParameterExamplesExtension(OpenApiParameter parameter, ParseNode node, OpenApiDocument hostDocument) + private static void LoadParameterExamplesExtension(OpenApiParameter parameter, ParseNode node, OpenApiDocument? hostDocument) { var examples = LoadExamplesExtension(node); node.Context.SetTempStorage(TempStorageKeys.Examples, examples, parameter); @@ -187,12 +257,12 @@ private static void ProcessIn(OpenApiParameter o, ParseNode n, OpenApiDocument h } } - public static IOpenApiParameter LoadParameter(ParseNode node, OpenApiDocument hostDocument) + public static IOpenApiParameter? LoadParameter(ParseNode node, OpenApiDocument hostDocument) { return LoadParameter(node, false, hostDocument); } - public static IOpenApiParameter LoadParameter(ParseNode node, bool loadRequestBody, OpenApiDocument hostDocument) + public static IOpenApiParameter? LoadParameter(ParseNode node, bool loadRequestBody, OpenApiDocument hostDocument) { // Reset the local variables every time this method is called. node.Context.SetTempStorage(TempStorageKeys.ParameterIsBodyOrFormData, false); @@ -226,7 +296,13 @@ public static IOpenApiParameter LoadParameter(ParseNode node, bool loadRequestBo node.Context.SetTempStorage("examples", null); } - var isBodyOrFormData = (bool)node.Context.GetFromTempStorage(TempStorageKeys.ParameterIsBodyOrFormData); + var isBodyOrFormData = false; + var paramData = node.Context.GetFromTempStorage(TempStorageKeys.ParameterIsBodyOrFormData); + if (paramData is bool boolValue) + { + isBodyOrFormData = boolValue; + } + if (isBodyOrFormData && !loadRequestBody) { return null; // Don't include Form or Body parameters when normal parameters are loaded. diff --git a/src/Microsoft.OpenApi/Reader/V2/OpenApiPathItemDeserializer.cs b/src/Microsoft.OpenApi/Reader/V2/OpenApiPathItemDeserializer.cs index 822f2d4ce..c0dec5050 100644 --- a/src/Microsoft.OpenApi/Reader/V2/OpenApiPathItemDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V2/OpenApiPathItemDeserializer.cs @@ -7,6 +7,7 @@ using System.Net.Http; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; +using Microsoft.OpenApi.Models.Interfaces; using Microsoft.OpenApi.Reader.ParseNodes; namespace Microsoft.OpenApi.Reader.V2 @@ -58,11 +59,13 @@ private static void LoadPathParameters(OpenApiPathItem pathItem, ParseNode node, node.Context.SetTempStorage(TempStorageKeys.BodyParameter, null); node.Context.SetTempStorage(TempStorageKeys.FormParameters, null); - pathItem.Parameters = node.CreateList(LoadParameter, hostDocument); + pathItem.Parameters = node.CreateList(LoadParameter, hostDocument) + .OfType() + .ToList(); // Build request body based on information determined while parsing OpenApiOperation var bodyParameter = node.Context.GetFromTempStorage(TempStorageKeys.BodyParameter); - if (bodyParameter != null) + if (bodyParameter is not null && pathItem.Operations is not null) { var requestBody = CreateRequestBody(node.Context, bodyParameter); foreach (var opPair in pathItem.Operations.Where(x => x.Value.RequestBody is null)) @@ -82,7 +85,7 @@ private static void LoadPathParameters(OpenApiPathItem pathItem, ParseNode node, else { var formParameters = node.Context.GetFromTempStorage>(TempStorageKeys.FormParameters); - if (formParameters != null) + if (formParameters is not null && pathItem.Operations is not null) { var requestBody = CreateFormBody(node.Context, formParameters); foreach (var opPair in pathItem.Operations.Where(x => x.Value.RequestBody is null)) diff --git a/src/Microsoft.OpenApi/Reader/V2/OpenApiResponseDeserializer.cs b/src/Microsoft.OpenApi/Reader/V2/OpenApiResponseDeserializer.cs index 514ed0b44..653208578 100644 --- a/src/Microsoft.OpenApi/Reader/V2/OpenApiResponseDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V2/OpenApiResponseDeserializer.cs @@ -105,7 +105,7 @@ private static void ProcessProduces(MapNode mapNode, OpenApiResponse response, P context.SetTempStorage(TempStorageKeys.ResponseProducesSet, true, response); } - private static void LoadResponseExamplesExtension(OpenApiResponse response, ParseNode node, OpenApiDocument hostDocument) + private static void LoadResponseExamplesExtension(OpenApiResponse response, ParseNode node, OpenApiDocument? hostDocument) { var examples = LoadExamplesExtension(node); node.Context.SetTempStorage(TempStorageKeys.Examples, examples, response); @@ -146,7 +146,7 @@ private static Dictionary LoadExamplesExtension(ParseNo return examples; } - private static void LoadExamples(OpenApiResponse response, ParseNode node, OpenApiDocument hostDocument) + private static void LoadExamples(OpenApiResponse response, ParseNode node, OpenApiDocument? hostDocument) { var mapNode = node.CheckMapNode("examples"); @@ -196,12 +196,14 @@ public static IOpenApiResponse LoadResponse(ParseNode node, OpenApiDocument host { property.ParseField(response, _responseFixedFields, _responsePatternFields, hostDocument); } - - foreach (var mediaType in response.Content.Values) + if (response.Content?.Values is not null) { - if (mediaType.Schema != null) + foreach (var mediaType in response.Content.Values) { - ProcessAnyFields(mapNode, mediaType, _mediaTypeAnyFields); + if (mediaType.Schema != null) + { + ProcessAnyFields(mapNode, mediaType, _mediaTypeAnyFields); + } } } diff --git a/src/Microsoft.OpenApi/Reader/V2/OpenApiSchemaDeserializer.cs b/src/Microsoft.OpenApi/Reader/V2/OpenApiSchemaDeserializer.cs index 87a8fdf8a..5597ed1b7 100644 --- a/src/Microsoft.OpenApi/Reader/V2/OpenApiSchemaDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V2/OpenApiSchemaDeserializer.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System.Collections.Generic; @@ -9,6 +9,7 @@ using Microsoft.OpenApi.Models.References; using Microsoft.OpenApi.Models.Interfaces; using System; +using System.Linq; namespace Microsoft.OpenApi.Reader.V2 { @@ -26,11 +27,25 @@ internal static partial class OpenApiV2Deserializer }, { "multipleOf", - (o, n, _) => o.MultipleOf = decimal.Parse(n.GetScalarValue(), NumberStyles.Float, CultureInfo.InvariantCulture) + (o, n, _) => + { + var multipleOf = n.GetScalarValue(); + if (multipleOf != null) + { + o.MultipleOf = decimal.Parse(multipleOf, NumberStyles.Float, CultureInfo.InvariantCulture); + } + } }, { "maximum", - (o, n,_) => o.Maximum = ParserHelper.ParseDecimalWithFallbackOnOverflow(n.GetScalarValue(), decimal.MaxValue) + (o, n,_) => + { + var max = n.GetScalarValue(); + if (max != null) + { + o.Maximum = ParserHelper.ParseDecimalWithFallbackOnOverflow(max, decimal.MaxValue); + } + } }, { "exclusiveMaximum", @@ -38,7 +53,14 @@ internal static partial class OpenApiV2Deserializer }, { "minimum", - (o, n, _) => o.Minimum = ParserHelper.ParseDecimalWithFallbackOnOverflow(n.GetScalarValue(), decimal.MinValue) + (o, n, _) => + { + var min = n.GetScalarValue(); + if (min != null) + { + o.Minimum = ParserHelper.ParseDecimalWithFallbackOnOverflow(min, decimal.MinValue); + } + } }, { "exclusiveMinimum", @@ -46,11 +68,25 @@ internal static partial class OpenApiV2Deserializer }, { "maxLength", - (o, n, _) => o.MaxLength = int.Parse(n.GetScalarValue(), CultureInfo.InvariantCulture) + (o, n, _) => + { + var maxLength = n.GetScalarValue(); + if (maxLength != null) + { + o.MaxLength = int.Parse(maxLength, CultureInfo.InvariantCulture); + } + } }, { "minLength", - (o, n, _) => o.MinLength = int.Parse(n.GetScalarValue(), CultureInfo.InvariantCulture) + (o, n, _) => + { + var minLength = n.GetScalarValue(); + if (minLength != null) + { + o.MinLength = int.Parse(minLength, CultureInfo.InvariantCulture); + } + } }, { "pattern", @@ -58,27 +94,68 @@ internal static partial class OpenApiV2Deserializer }, { "maxItems", - (o, n, _) => o.MaxItems = int.Parse(n.GetScalarValue(), CultureInfo.InvariantCulture) + (o, n, _) => + { + var maxItems = n.GetScalarValue(); + if (maxItems != null) + { + o.MaxItems = int.Parse(maxItems, CultureInfo.InvariantCulture); + } + } }, { "minItems", - (o, n, _) => o.MinItems = int.Parse(n.GetScalarValue(), CultureInfo.InvariantCulture) + (o, n, _) => + { + var minItems = n.GetScalarValue(); + if (minItems != null) + { + o.MinItems = int.Parse(minItems, CultureInfo.InvariantCulture); + } + } }, { "uniqueItems", - (o, n, _) => o.UniqueItems = bool.Parse(n.GetScalarValue()) + (o, n, _) => + { + var uniqueItems = n.GetScalarValue(); + if (uniqueItems != null) + { + o.UniqueItems = bool.Parse(uniqueItems); + } + } }, { "maxProperties", - (o, n, _) => o.MaxProperties = int.Parse(n.GetScalarValue(), CultureInfo.InvariantCulture) + (o, n, _) => + { + var maxProps = n.GetScalarValue(); + if (maxProps != null) + { + o.MaxProperties = int.Parse(maxProps, CultureInfo.InvariantCulture); + } + } }, { "minProperties", - (o, n, _) => o.MinProperties = int.Parse(n.GetScalarValue(), CultureInfo.InvariantCulture) + (o, n, _) => + { + var minProps = n.GetScalarValue(); + if (minProps != null) + { + o.MinProperties = int.Parse(minProps, CultureInfo.InvariantCulture); + } + } }, { "required", - (o, n, doc) => o.Required = new HashSet(n.CreateSimpleList((n2, p) => n2.GetScalarValue(), doc)) + (o, n, doc) => + { + o.Required = new HashSet( + n.CreateSimpleList((n2, p) => + n2.GetScalarValue(), doc) + .Where(s => s != null)!); + } }, { "enum", @@ -87,7 +164,14 @@ internal static partial class OpenApiV2Deserializer { "type", - (o, n, _) => o.Type = n.GetScalarValue().ToJsonSchemaType() + (o, n, _) => + { + var type = n.GetScalarValue(); + if (type != null) + { + o.Type = type.ToJsonSchemaType(); + } + } }, { "allOf", @@ -106,7 +190,11 @@ internal static partial class OpenApiV2Deserializer { if (n is ValueNode) { - o.AdditionalPropertiesAllowed = bool.Parse(n.GetScalarValue()); + var value = n.GetScalarValue(); + if (value is not null) + { + o.AdditionalPropertiesAllowed = bool.Parse(value); + } } else { @@ -137,7 +225,14 @@ internal static partial class OpenApiV2Deserializer }, { "readOnly", - (o, n, _) => o.ReadOnly = bool.Parse(n.GetScalarValue()) + (o, n, _) => + { + var readOnly = n.GetScalarValue(); + if (readOnly is not null) + { + o.ReadOnly = bool.Parse(readOnly); + } + } }, { "xml", diff --git a/src/Microsoft.OpenApi/Reader/V2/OpenApiSecurityRequirementDeserializer.cs b/src/Microsoft.OpenApi/Reader/V2/OpenApiSecurityRequirementDeserializer.cs index 7b47ff6c5..1fec679df 100644 --- a/src/Microsoft.OpenApi/Reader/V2/OpenApiSecurityRequirementDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V2/OpenApiSecurityRequirementDeserializer.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. +using System.Linq; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.Interfaces; using Microsoft.OpenApi.Models.References; @@ -26,7 +27,9 @@ public static OpenApiSecurityRequirement LoadSecurityRequirement(ParseNode node, hostDocument, property.Name); - var scopes = property.Value.CreateSimpleList((n2, p) => n2.GetScalarValue(), hostDocument); + var scopes = property.Value.CreateSimpleList((n2, p) => n2.GetScalarValue(), hostDocument) + .OfType() + .ToList(); if (scheme != null) { @@ -44,7 +47,7 @@ public static OpenApiSecurityRequirement LoadSecurityRequirement(ParseNode node, } private static OpenApiSecuritySchemeReference LoadSecuritySchemeByReference( - OpenApiDocument openApiDocument, + OpenApiDocument? openApiDocument, string schemeName) { return new OpenApiSecuritySchemeReference(schemeName, openApiDocument); diff --git a/src/Microsoft.OpenApi/Reader/V2/OpenApiSecuritySchemeDeserializer.cs b/src/Microsoft.OpenApi/Reader/V2/OpenApiSecuritySchemeDeserializer.cs index 0dc329f43..af9ff89f9 100644 --- a/src/Microsoft.OpenApi/Reader/V2/OpenApiSecuritySchemeDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V2/OpenApiSecuritySchemeDeserializer.cs @@ -1,7 +1,8 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System; +using System.Linq; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.Interfaces; @@ -15,9 +16,9 @@ namespace Microsoft.OpenApi.Reader.V2 /// internal static partial class OpenApiV2Deserializer { - private static string _flowValue; + private static string? _flowValue; - private static OpenApiOAuthFlow _flow; + private static OpenApiOAuthFlow? _flow; private static readonly FixedFieldMap _securitySchemeFixedFields = new() @@ -50,7 +51,7 @@ internal static partial class OpenApiV2Deserializer }, {"description", (o, n, _) => o.Description = n.GetScalarValue()}, {"name", (o, n, _) => o.Name = n.GetScalarValue()}, - {"in", (o, n, _) => + {"in", (o, n, _) => { if (!n.GetScalarValue().TryGetEnumFromDisplayName(n.Context, out var _in)) { @@ -64,14 +65,36 @@ internal static partial class OpenApiV2Deserializer }, { "authorizationUrl", - (_, n, _) => _flow.AuthorizationUrl = new(n.GetScalarValue(), UriKind.RelativeOrAbsolute) + (_, n, _) => + { + var scalarValue = n.GetScalarValue(); + if (_flow is not null && scalarValue is not null) + { + _flow.AuthorizationUrl = new(scalarValue, UriKind.RelativeOrAbsolute); + } + } }, { "tokenUrl", - (_, n, _) => _flow.TokenUrl = new(n.GetScalarValue(), UriKind.RelativeOrAbsolute) + (_, n, _) => + { + var scalarValue = n.GetScalarValue(); + if (_flow is not null && scalarValue is not null) + { + _flow.TokenUrl = new(scalarValue, UriKind.RelativeOrAbsolute); + } + } }, { - "scopes", (_, n, _) => _flow.Scopes = n.CreateSimpleMap(LoadString) + "scopes", (_, n, _) => + { + if (_flow is not null) + { + _flow.Scopes = n.CreateSimpleMap(LoadString) + .Where(kv => kv.Value != null) + .ToDictionary(kv => kv.Key, kv => kv.Value!); + } + } } }; diff --git a/src/Microsoft.OpenApi/Reader/V2/OpenApiV2Deserializer.cs b/src/Microsoft.OpenApi/Reader/V2/OpenApiV2Deserializer.cs index 83505670d..dc347615e 100644 --- a/src/Microsoft.OpenApi/Reader/V2/OpenApiV2Deserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V2/OpenApiV2Deserializer.cs @@ -20,12 +20,12 @@ namespace Microsoft.OpenApi.Reader.V2 internal static partial class OpenApiV2Deserializer { private static void ParseMap( - MapNode mapNode, + MapNode? mapNode, T domainObject, FixedFieldMap fixedFieldMap, PatternFieldMap patternFieldMap, - List requiredFields = null, - OpenApiDocument doc = null) + OpenApiDocument doc, + List? requiredFields = null) { if (mapNode == null) { @@ -80,7 +80,7 @@ public static JsonNode LoadAny(ParseNode node, OpenApiDocument hostDocument) private static IOpenApiExtension LoadExtension(string name, ParseNode node) { - if (node.Context.ExtensionParsers.TryGetValue(name, out var parser)) + if (node.Context.ExtensionParsers is not null && node.Context.ExtensionParsers.TryGetValue(name, out var parser)) { return parser(node.CreateAny(), OpenApiSpecVersion.OpenApi2_0); } @@ -90,18 +90,18 @@ private static IOpenApiExtension LoadExtension(string name, ParseNode node) } } - private static string LoadString(ParseNode node) + private static string? LoadString(ParseNode node) { return node.GetScalarValue(); } - private static (string, string) GetReferenceIdAndExternalResource(string pointer) + private static (string, string?) GetReferenceIdAndExternalResource(string pointer) { var refSegments = pointer.Split('/'); - var refId = refSegments.Last(); - var isExternalResource = !refSegments.First().StartsWith("#", StringComparison.OrdinalIgnoreCase); + var refId = refSegments[refSegments.Count() -1]; + var isExternalResource = !refSegments[0].StartsWith("#", StringComparison.OrdinalIgnoreCase); - string externalResource = isExternalResource ? $"{refSegments.First()}/{refSegments[1].TrimEnd('#')}" : null; + string? externalResource = isExternalResource ? $"{refSegments[0]}/{refSegments[1].TrimEnd('#')}" : null; return (refId, externalResource); } diff --git a/src/Microsoft.OpenApi/Reader/V2/OpenApiV2VersionService.cs b/src/Microsoft.OpenApi/Reader/V2/OpenApiV2VersionService.cs index c4186bb25..d92e9ce78 100644 --- a/src/Microsoft.OpenApi/Reader/V2/OpenApiV2VersionService.cs +++ b/src/Microsoft.OpenApi/Reader/V2/OpenApiV2VersionService.cs @@ -29,7 +29,7 @@ public OpenApiV2VersionService(OpenApiDiagnostic diagnostic) Diagnostic = diagnostic; } - private readonly Dictionary> _loaders = new() + private readonly Dictionary> _loaders = new() { [typeof(OpenApiAny)] = OpenApiV2Deserializer.LoadAny, [typeof(OpenApiContact)] = OpenApiV2Deserializer.LoadContact, @@ -50,173 +50,18 @@ public OpenApiV2VersionService(OpenApiDiagnostic diagnostic) [typeof(OpenApiXml)] = OpenApiV2Deserializer.LoadXml }; - private static OpenApiReference ParseLocalReference(string localReference) - { - if (string.IsNullOrWhiteSpace(localReference)) - { - throw new ArgumentException( - string.Format( - SRResource.ArgumentNullOrWhiteSpace, - nameof(localReference))); - } - - var segments = localReference.Split('/'); - - // /definitions/Pet/... - if (segments.Length >= 3) - { - var referenceType = ParseReferenceType(segments[1]); - var id = localReference.Substring( - segments[0].Length + "/".Length + segments[1].Length + "/".Length); - - return new() { Type = referenceType, Id = id }; - } - - throw new OpenApiException( - string.Format( - SRResource.ReferenceHasInvalidFormat, - localReference)); - } - - private static ReferenceType ParseReferenceType(string referenceTypeName) - { - switch (referenceTypeName) - { - case "definitions": - return ReferenceType.Schema; - - case "parameters": - return ReferenceType.Parameter; - - case "responses": - return ReferenceType.Response; - - case "headers": - return ReferenceType.Header; - - case "tags": - return ReferenceType.Tag; - - case "securityDefinitions": - return ReferenceType.SecurityScheme; - - default: - throw new OpenApiReaderException($"Unknown reference type '{referenceTypeName}'"); - } - } - - private static ReferenceType GetReferenceTypeV2FromName(string referenceType) - { - switch (referenceType) - { - case "definitions": - return ReferenceType.Schema; - - case "parameters": - return ReferenceType.Parameter; - - case "responses": - return ReferenceType.Response; - - case "tags": - return ReferenceType.Tag; - - case "securityDefinitions": - return ReferenceType.SecurityScheme; - - default: - throw new ArgumentException(); - } - } - - /// - /// Parse the string to a object. - /// - public OpenApiReference ConvertToOpenApiReference(string reference, ReferenceType? type, string summary = null, string description = null) - { - if (!string.IsNullOrWhiteSpace(reference)) - { - var segments = reference.Split('#'); - if (segments.Length == 1) - { - // Either this is an external reference as an entire file - // or a simple string-style reference for tag and security scheme. - if (type == null) - { - // "$ref": "Pet.json" - return new() - { - ExternalResource = segments[0] - }; - } - - if (type is ReferenceType.Tag or ReferenceType.SecurityScheme) - { - return new() - { - Type = type, - Id = reference - }; - } - } - else if (segments.Length == 2) - { - if (reference.StartsWith("#", StringComparison.OrdinalIgnoreCase)) - { - // "$ref": "#/definitions/Pet" - try - { - return ParseLocalReference(segments[1]); - } - catch (OpenApiException ex) - { - Diagnostic.Errors.Add(new(ex)); - return null; - } - } - - // Where fragments point into a non-OpenAPI document, the id will be the complete fragment identifier - var id = segments[1]; - // $ref: externalSource.yaml#/Pet - if (id.StartsWith("/definitions/", StringComparison.Ordinal)) - { - var localSegments = id.Split('/'); - var referencedType = GetReferenceTypeV2FromName(localSegments[1]); - if (type == null) - { - type = referencedType; - } - else - { - if (type != referencedType) - { - throw new OpenApiException("Referenced type mismatch"); - } - } - id = localSegments[2]; - } - - // $ref: externalSource.yaml#/Pet - return new() - { - ExternalResource = segments[0], - Type = type, - Id = id - }; - } - } - - throw new OpenApiException(string.Format(SRResource.ReferenceHasInvalidFormat, reference)); - } - public OpenApiDocument LoadDocument(RootNode rootNode) { return OpenApiV2Deserializer.LoadOpenApi(rootNode); } - public T LoadElement(ParseNode node, OpenApiDocument doc) where T : IOpenApiElement + public T? LoadElement(ParseNode node, OpenApiDocument doc) where T : IOpenApiElement { - return (T)_loaders[typeof(T)](node, doc); + if (_loaders.TryGetValue(typeof(T), out var loader) && loader(node, doc) is T result) + { + return result; + } + return default; } /// diff --git a/src/Microsoft.OpenApi/Reader/V2/OpenApiXmlDeserializer.cs b/src/Microsoft.OpenApi/Reader/V2/OpenApiXmlDeserializer.cs index 38acf840d..a1eb9ba9f 100644 --- a/src/Microsoft.OpenApi/Reader/V2/OpenApiXmlDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V2/OpenApiXmlDeserializer.cs @@ -24,9 +24,10 @@ internal static partial class OpenApiV2Deserializer { "namespace", (o, n, _) => { - if (Uri.IsWellFormedUriString(n.GetScalarValue(), UriKind.Absolute)) + var scalarValue = n.GetScalarValue(); + if (Uri.IsWellFormedUriString(scalarValue, UriKind.Absolute) && scalarValue is not null) { - o.Namespace = new(n.GetScalarValue(), UriKind.Absolute); + o.Namespace = new(scalarValue, UriKind.Absolute); } else { @@ -40,11 +41,25 @@ internal static partial class OpenApiV2Deserializer }, { "attribute", - (o, n, _) => o.Attribute = bool.Parse(n.GetScalarValue()) + (o, n, _) => + { + var attribute = n.GetScalarValue(); + if (attribute is not null) + { + o.Attribute = bool.Parse(attribute); + } + } }, { "wrapped", - (o, n, _) => o.Wrapped = bool.Parse(n.GetScalarValue()) + (o, n, _) => + { + var wrapped = n.GetScalarValue(); + if (wrapped is not null) + { + o.Wrapped = bool.Parse(wrapped); + } + } }, }; diff --git a/src/Microsoft.OpenApi/Reader/V3/OpenApiContactDeserializer.cs b/src/Microsoft.OpenApi/Reader/V3/OpenApiContactDeserializer.cs index 7eab275c8..21b11b794 100644 --- a/src/Microsoft.OpenApi/Reader/V3/OpenApiContactDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V3/OpenApiContactDeserializer.cs @@ -26,7 +26,14 @@ internal static partial class OpenApiV3Deserializer }, { "url", - (o, n, _) => o.Url = new(n.GetScalarValue(), UriKind.RelativeOrAbsolute) + (o, n, t) => + { + var url = n.GetScalarValue(); + if (url != null) + { + o.Url = new(url, UriKind.RelativeOrAbsolute); + } + } }, }; diff --git a/src/Microsoft.OpenApi/Reader/V3/OpenApiDiscriminatorDeserializer.cs b/src/Microsoft.OpenApi/Reader/V3/OpenApiDiscriminatorDeserializer.cs index 5f9db648e..1493283c0 100644 --- a/src/Microsoft.OpenApi/Reader/V3/OpenApiDiscriminatorDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V3/OpenApiDiscriminatorDeserializer.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. +using System.Linq; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Reader.ParseNodes; @@ -21,7 +22,7 @@ internal static partial class OpenApiV3Deserializer }, { "mapping", - (o, n, _) => o.Mapping = n.CreateSimpleMap(LoadString) + (o, n, _) => o.Mapping = n.CreateSimpleMap(LoadString).Where(kv => kv.Value is not null).ToDictionary(kv => kv.Key, kv => kv.Value!) } }; diff --git a/src/Microsoft.OpenApi/Reader/V3/OpenApiDocumentDeserializer.cs b/src/Microsoft.OpenApi/Reader/V3/OpenApiDocumentDeserializer.cs index 044542d21..6e5fb952b 100644 --- a/src/Microsoft.OpenApi/Reader/V3/OpenApiDocumentDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V3/OpenApiDocumentDeserializer.cs @@ -46,7 +46,7 @@ public static OpenApiDocument LoadOpenApi(RootNode rootNode) ParseMap(openApiNode, openApiDoc, _openApiFixedFields, _openApiPatternFields, openApiDoc); // Register components - openApiDoc.Workspace.RegisterComponents(openApiDoc); + openApiDoc.Workspace?.RegisterComponents(openApiDoc); return openApiDoc; } diff --git a/src/Microsoft.OpenApi/Reader/V3/OpenApiEncodingDeserializer.cs b/src/Microsoft.OpenApi/Reader/V3/OpenApiEncodingDeserializer.cs index 2d324745d..c2d88936f 100644 --- a/src/Microsoft.OpenApi/Reader/V3/OpenApiEncodingDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V3/OpenApiEncodingDeserializer.cs @@ -37,11 +37,25 @@ internal static partial class OpenApiV3Deserializer }, { "explode", - (o, n, _) => o.Explode = bool.Parse(n.GetScalarValue()) + (o, n, _) => + { + var explode = n.GetScalarValue(); + if (explode != null) + { + o.Explode = bool.Parse(explode); + } + } }, { "allowedReserved", - (o, n, _) => o.AllowReserved = bool.Parse(n.GetScalarValue()) + (o, n, _) => + { + var allowReserved = n.GetScalarValue(); + if (allowReserved != null) + { + o.AllowReserved = bool.Parse(allowReserved); + } + } }, }; diff --git a/src/Microsoft.OpenApi/Reader/V3/OpenApiExternalDocsDeserializer.cs b/src/Microsoft.OpenApi/Reader/V3/OpenApiExternalDocsDeserializer.cs index 0d8c25b05..7f357b947 100644 --- a/src/Microsoft.OpenApi/Reader/V3/OpenApiExternalDocsDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V3/OpenApiExternalDocsDeserializer.cs @@ -24,8 +24,15 @@ internal static partial class OpenApiV3Deserializer }, { "url", - (o, n, _) => o.Url = new(n.GetScalarValue(), UriKind.RelativeOrAbsolute) - }, + (o, n, _) => + { + var url = n.GetScalarValue(); + if (url != null) + { + o.Url = new(url, UriKind.RelativeOrAbsolute); + } + } + } }; private static readonly PatternFieldMap _externalDocsPatternFields = diff --git a/src/Microsoft.OpenApi/Reader/V3/OpenApiHeaderDeserializer.cs b/src/Microsoft.OpenApi/Reader/V3/OpenApiHeaderDeserializer.cs index 94350d429..4b3318357 100644 --- a/src/Microsoft.OpenApi/Reader/V3/OpenApiHeaderDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V3/OpenApiHeaderDeserializer.cs @@ -24,19 +24,47 @@ internal static partial class OpenApiV3Deserializer }, { "required", - (o, n, _) => o.Required = bool.Parse(n.GetScalarValue()) + (o, n, _) => + { + var required = n.GetScalarValue(); + if (required != null) + { + o.Required = bool.Parse(required); + } + } }, { "deprecated", - (o, n, _) => o.Deprecated = bool.Parse(n.GetScalarValue()) + (o, n, _) => + { + var deprecated = n.GetScalarValue(); + if (deprecated != null) + { + o.Deprecated = bool.Parse(deprecated); + } + } }, { "allowEmptyValue", - (o, n, _) => o.AllowEmptyValue = bool.Parse(n.GetScalarValue()) + (o, n, _) => + { + var allowEmptyVal = n.GetScalarValue(); + if (allowEmptyVal != null) + { + o.AllowEmptyValue = bool.Parse(allowEmptyVal); + } + } }, { "allowReserved", - (o, n, _) => o.AllowReserved = bool.Parse(n.GetScalarValue()) + (o, n, _) => + { + var allowReserved = n.GetScalarValue(); + if (allowReserved != null) + { + o.AllowReserved = bool.Parse(allowReserved); + } + } }, { "style", @@ -51,7 +79,14 @@ internal static partial class OpenApiV3Deserializer }, { "explode", - (o, n, _) => o.Explode = bool.Parse(n.GetScalarValue()) + (o, n, _) => + { + var explode = n.GetScalarValue(); + if (explode != null) + { + o.Explode = bool.Parse(explode); + } + } }, { "schema", diff --git a/src/Microsoft.OpenApi/Reader/V3/OpenApiInfoDeserializer.cs b/src/Microsoft.OpenApi/Reader/V3/OpenApiInfoDeserializer.cs index 48979439d..2686e5d1a 100644 --- a/src/Microsoft.OpenApi/Reader/V3/OpenApiInfoDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V3/OpenApiInfoDeserializer.cs @@ -30,7 +30,14 @@ internal static partial class OpenApiV3Deserializer }, { "termsOfService", - (o, n, _) => o.TermsOfService = new(n.GetScalarValue(), UriKind.RelativeOrAbsolute) + (o, n, _) => + { + var terms = n.GetScalarValue(); + if (terms != null) + { + o.TermsOfService = new(terms, UriKind.RelativeOrAbsolute); + } + } }, { "contact", diff --git a/src/Microsoft.OpenApi/Reader/V3/OpenApiLicenseDeserializer.cs b/src/Microsoft.OpenApi/Reader/V3/OpenApiLicenseDeserializer.cs index 4ecdce151..eaf9ba24f 100644 --- a/src/Microsoft.OpenApi/Reader/V3/OpenApiLicenseDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V3/OpenApiLicenseDeserializer.cs @@ -22,7 +22,14 @@ internal static partial class OpenApiV3Deserializer }, { "url", - (o, n, _) => o.Url = new(n.GetScalarValue(), UriKind.RelativeOrAbsolute) + (o, n, _) => + { + var url = n.GetScalarValue(); + if (url != null) + { + o.Url = new(url, UriKind.RelativeOrAbsolute); + } + } }, }; diff --git a/src/Microsoft.OpenApi/Reader/V3/OpenApiMediaTypeDeserializer.cs b/src/Microsoft.OpenApi/Reader/V3/OpenApiMediaTypeDeserializer.cs index 6fd96b38d..b0e99bd44 100644 --- a/src/Microsoft.OpenApi/Reader/V3/OpenApiMediaTypeDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V3/OpenApiMediaTypeDeserializer.cs @@ -54,8 +54,8 @@ internal static partial class OpenApiV3Deserializer }; private static readonly AnyMapFieldMap _mediaTypeAnyMapOpenApiExampleFields = - new() - { + new() + { { OpenApiConstants.Examples, new( diff --git a/src/Microsoft.OpenApi/Reader/V3/OpenApiOAuthFlowDeserializer.cs b/src/Microsoft.OpenApi/Reader/V3/OpenApiOAuthFlowDeserializer.cs index d60cf0aa5..1771f1407 100644 --- a/src/Microsoft.OpenApi/Reader/V3/OpenApiOAuthFlowDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V3/OpenApiOAuthFlowDeserializer.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. using System; +using System.Linq; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Reader.ParseNodes; @@ -19,17 +20,38 @@ internal static partial class OpenApiV3Deserializer { { "authorizationUrl", - (o, n, _) => o.AuthorizationUrl = new(n.GetScalarValue(), UriKind.RelativeOrAbsolute) + (o, n, _) => + { + var url = n.GetScalarValue(); + if (url != null) + { + o.AuthorizationUrl = new(url, UriKind.RelativeOrAbsolute); + } + } }, { "tokenUrl", - (o, n, _) => o.TokenUrl = new(n.GetScalarValue(), UriKind.RelativeOrAbsolute) + (o, n, _) => + { + var url = n.GetScalarValue(); + if (url != null) + { + o.TokenUrl = new(url, UriKind.RelativeOrAbsolute); + } + } }, { "refreshUrl", - (o, n, _) => o.RefreshUrl = new(n.GetScalarValue(), UriKind.RelativeOrAbsolute) + (o, n, _) => + { + var url = n.GetScalarValue(); + if (url != null) + { + o.RefreshUrl = new(url, UriKind.RelativeOrAbsolute); + } + } }, - {"scopes", (o, n, _) => o.Scopes = n.CreateSimpleMap(LoadString)} + {"scopes", (o, n, _) => o.Scopes = n.CreateSimpleMap(LoadString).Where(kv => kv.Value is not null).ToDictionary(kv => kv.Key, kv => kv.Value!)} }; private static readonly PatternFieldMap _oAuthFlowPatternFields = diff --git a/src/Microsoft.OpenApi/Reader/V3/OpenApiOperationDeserializer.cs b/src/Microsoft.OpenApi/Reader/V3/OpenApiOperationDeserializer.cs index 9fca4d14b..00fdeb3ee 100644 --- a/src/Microsoft.OpenApi/Reader/V3/OpenApiOperationDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V3/OpenApiOperationDeserializer.cs @@ -61,7 +61,14 @@ internal static partial class OpenApiV3Deserializer }, { "deprecated", - (o, n, _) => o.Deprecated = bool.Parse(n.GetScalarValue()) + (o, n, _) => + { + var deprecated = n.GetScalarValue(); + if (deprecated != null) + { + o.Deprecated = bool.Parse(deprecated); + } + } }, { "security", @@ -91,7 +98,7 @@ internal static OpenApiOperation LoadOperation(ParseNode node, OpenApiDocument h } private static OpenApiTagReference LoadTagByReference( - string tagName, OpenApiDocument hostDocument) + string tagName, OpenApiDocument? hostDocument) { return new OpenApiTagReference(tagName, hostDocument); } diff --git a/src/Microsoft.OpenApi/Reader/V3/OpenApiParameterDeserializer.cs b/src/Microsoft.OpenApi/Reader/V3/OpenApiParameterDeserializer.cs index 7d2c5074b..33e67b953 100644 --- a/src/Microsoft.OpenApi/Reader/V3/OpenApiParameterDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V3/OpenApiParameterDeserializer.cs @@ -39,19 +39,47 @@ internal static partial class OpenApiV3Deserializer }, { "required", - (o, n, _) => o.Required = bool.Parse(n.GetScalarValue()) + (o, n, t) => + { + var required = n.GetScalarValue(); + if (required != null) + { + o.Required = bool.Parse(required); + } + } }, { "deprecated", - (o, n, _) => o.Deprecated = bool.Parse(n.GetScalarValue()) + (o, n, t) => + { + var deprecated = n.GetScalarValue(); + if (deprecated != null) + { + o.Deprecated = bool.Parse(deprecated); + } + } }, { "allowEmptyValue", - (o, n, _) => o.AllowEmptyValue = bool.Parse(n.GetScalarValue()) + (o, n, t) => + { + var allowEmptyValue = n.GetScalarValue(); + if (allowEmptyValue != null) + { + o.AllowEmptyValue = bool.Parse(allowEmptyValue); + } + } }, { "allowReserved", - (o, n, _) => o.AllowReserved = bool.Parse(n.GetScalarValue()) + (o, n, _) => + { + var allowReserved = n.GetScalarValue(); + if (allowReserved != null) + { + o.AllowReserved = bool.Parse(allowReserved); + } + } }, { "style", @@ -66,7 +94,14 @@ internal static partial class OpenApiV3Deserializer }, { "explode", - (o, n, _) => o.Explode = bool.Parse(n.GetScalarValue()) + (o, n, _) => + { + var explode = n.GetScalarValue(); + if (explode != null) + { + o.Explode = bool.Parse(explode); + } + } }, { "schema", diff --git a/src/Microsoft.OpenApi/Reader/V3/OpenApiRequestBodyDeserializer.cs b/src/Microsoft.OpenApi/Reader/V3/OpenApiRequestBodyDeserializer.cs index ac007d813..339ca437e 100644 --- a/src/Microsoft.OpenApi/Reader/V3/OpenApiRequestBodyDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V3/OpenApiRequestBodyDeserializer.cs @@ -29,7 +29,14 @@ internal static partial class OpenApiV3Deserializer }, { "required", - (o, n, _) => o.Required = bool.Parse(n.GetScalarValue()) + (o, n, _) => + { + var required = n.GetScalarValue(); + if (required != null) + { + o.Required = bool.Parse(required); + } + } }, }; diff --git a/src/Microsoft.OpenApi/Reader/V3/OpenApiSchemaDeserializer.cs b/src/Microsoft.OpenApi/Reader/V3/OpenApiSchemaDeserializer.cs index 2cc13484f..464d6b1b5 100644 --- a/src/Microsoft.OpenApi/Reader/V3/OpenApiSchemaDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V3/OpenApiSchemaDeserializer.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using Microsoft.OpenApi.Extensions; @@ -9,6 +9,7 @@ using System; using System.Collections.Generic; using System.Globalization; +using System.Linq; namespace Microsoft.OpenApi.Reader.V3 { @@ -26,11 +27,25 @@ internal static partial class OpenApiV3Deserializer }, { "multipleOf", - (o, n, _) => o.MultipleOf = decimal.Parse(n.GetScalarValue(), NumberStyles.Float, CultureInfo.InvariantCulture) + (o, n, _) => + { + var multipleOf = n.GetScalarValue(); + if (multipleOf != null) + { + o.MultipleOf = decimal.Parse(multipleOf, NumberStyles.Float, CultureInfo.InvariantCulture); + } + } }, { "maximum", - (o, n, _) => o.Maximum = ParserHelper.ParseDecimalWithFallbackOnOverflow(n.GetScalarValue(), decimal.MaxValue) + (o, n,_) => + { + var max = n.GetScalarValue(); + if (max != null) + { + o.Maximum = ParserHelper.ParseDecimalWithFallbackOnOverflow(max, decimal.MaxValue); + } + } }, { "exclusiveMaximum", @@ -38,7 +53,14 @@ internal static partial class OpenApiV3Deserializer }, { "minimum", - (o, n, _) => o.Minimum = ParserHelper.ParseDecimalWithFallbackOnOverflow(n.GetScalarValue(), decimal.MinValue) + (o, n, _) => + { + var min = n.GetScalarValue(); + if (min != null) + { + o.Minimum = ParserHelper.ParseDecimalWithFallbackOnOverflow(min, decimal.MinValue); + } + } }, { "exclusiveMinimum", @@ -46,11 +68,25 @@ internal static partial class OpenApiV3Deserializer }, { "maxLength", - (o, n, _) => o.MaxLength = int.Parse(n.GetScalarValue(), CultureInfo.InvariantCulture) + (o, n, _) => + { + var maxLength = n.GetScalarValue(); + if (maxLength != null) + { + o.MaxLength = int.Parse(maxLength, CultureInfo.InvariantCulture); + } + } }, { "minLength", - (o, n, _) => o.MinLength = int.Parse(n.GetScalarValue(), CultureInfo.InvariantCulture) + (o, n, _) => + { + var minLength = n.GetScalarValue(); + if (minLength != null) + { + o.MinLength = int.Parse(minLength, CultureInfo.InvariantCulture); + } + } }, { "pattern", @@ -58,27 +94,62 @@ internal static partial class OpenApiV3Deserializer }, { "maxItems", - (o, n, _) => o.MaxItems = int.Parse(n.GetScalarValue(), CultureInfo.InvariantCulture) + (o, n, _) => + { + var maxItems = n.GetScalarValue(); + if (maxItems != null) + { + o.MaxItems = int.Parse(maxItems, CultureInfo.InvariantCulture); + } + } }, { "minItems", - (o, n, _) => o.MinItems = int.Parse(n.GetScalarValue(), CultureInfo.InvariantCulture) + (o, n, _) => + { + var minItems = n.GetScalarValue(); + if (minItems != null) + { + o.MinItems = int.Parse(minItems, CultureInfo.InvariantCulture); + } + } }, { "uniqueItems", - (o, n, _) => o.UniqueItems = bool.Parse(n.GetScalarValue()) + (o, n, _) => + { + var uniqueItems = n.GetScalarValue(); + if (uniqueItems != null) + { + o.UniqueItems = bool.Parse(uniqueItems); + } + } }, { "maxProperties", - (o, n, _) => o.MaxProperties = int.Parse(n.GetScalarValue(), CultureInfo.InvariantCulture) + (o, n, _) => + { + var maxProps = n.GetScalarValue(); + if (maxProps != null) + { + o.MaxProperties = int.Parse(maxProps, CultureInfo.InvariantCulture); + } + } }, { "minProperties", - (o, n, _) => o.MinProperties = int.Parse(n.GetScalarValue(), CultureInfo.InvariantCulture) + (o, n, _) => + { + var minProps = n.GetScalarValue(); + if (minProps != null) + { + o.MinProperties = int.Parse(minProps, CultureInfo.InvariantCulture); + } + } }, { "required", - (o, n, doc) => o.Required = new HashSet(n.CreateSimpleList((n2, p) => n2.GetScalarValue(), doc)) + (o, n, doc) => o.Required = new HashSet(n.CreateSimpleList((n2, p) => n2.GetScalarValue(), doc).Where(s => s != null)) }, { "enum", @@ -87,7 +158,7 @@ internal static partial class OpenApiV3Deserializer { "type", (o, n, _) => { - var type = n.GetScalarValue().ToJsonSchemaType(); + var type = n.GetScalarValue()?.ToJsonSchemaType(); // so we don't loose the value from nullable if (o.Type.HasValue) o.Type |= type; @@ -124,7 +195,11 @@ internal static partial class OpenApiV3Deserializer { if (n is ValueNode) { - o.AdditionalPropertiesAllowed = bool.Parse(n.GetScalarValue()); + var value = n.GetScalarValue(); + if (value is not null) + { + o.AdditionalPropertiesAllowed = bool.Parse(value); + } } else { @@ -163,11 +238,25 @@ internal static partial class OpenApiV3Deserializer }, { "readOnly", - (o, n, _) => o.ReadOnly = bool.Parse(n.GetScalarValue()) + (o, n, _) => + { + var readOnly = n.GetScalarValue(); + if (readOnly != null) + { + o.ReadOnly = bool.Parse(readOnly); + } + } }, { "writeOnly", - (o, n, _) => o.WriteOnly = bool.Parse(n.GetScalarValue()) + (o, n, _) => + { + var writeOnly = n.GetScalarValue(); + if (writeOnly != null) + { + o.WriteOnly = bool.Parse(writeOnly); + } + } }, { "xml", @@ -183,7 +272,14 @@ internal static partial class OpenApiV3Deserializer }, { "deprecated", - (o, n, _) => o.Deprecated = bool.Parse(n.GetScalarValue()) + (o, n, t) => + { + var deprecated = n.GetScalarValue(); + if (deprecated != null) + { + o.Deprecated = bool.Parse(deprecated); + } + } }, }; diff --git a/src/Microsoft.OpenApi/Reader/V3/OpenApiSecurityRequirementDeserializer.cs b/src/Microsoft.OpenApi/Reader/V3/OpenApiSecurityRequirementDeserializer.cs index 030f2ef34..018ca26ab 100644 --- a/src/Microsoft.OpenApi/Reader/V3/OpenApiSecurityRequirementDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V3/OpenApiSecurityRequirementDeserializer.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. +using System.Linq; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.Interfaces; using Microsoft.OpenApi.Models.References; @@ -24,7 +25,9 @@ public static OpenApiSecurityRequirement LoadSecurityRequirement(ParseNode node, { var scheme = LoadSecuritySchemeByReference(hostDocument, property.Name); - var scopes = property.Value.CreateSimpleList((value, p) => value.GetScalarValue(), hostDocument); + var scopes = property.Value.CreateSimpleList((n2, p) => n2.GetScalarValue(), hostDocument) + .OfType() + .ToList(); if (scheme != null) { @@ -41,7 +44,7 @@ public static OpenApiSecurityRequirement LoadSecurityRequirement(ParseNode node, } private static OpenApiSecuritySchemeReference LoadSecuritySchemeByReference( - OpenApiDocument openApiDocument, + OpenApiDocument? openApiDocument, string schemeName) { return new OpenApiSecuritySchemeReference(schemeName, openApiDocument); diff --git a/src/Microsoft.OpenApi/Reader/V3/OpenApiSecuritySchemeDeserializer.cs b/src/Microsoft.OpenApi/Reader/V3/OpenApiSecuritySchemeDeserializer.cs index 993279f1e..b01ece23f 100644 --- a/src/Microsoft.OpenApi/Reader/V3/OpenApiSecuritySchemeDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V3/OpenApiSecuritySchemeDeserializer.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System; @@ -59,7 +59,14 @@ internal static partial class OpenApiV3Deserializer }, { "openIdConnectUrl", - (o, n, _) => o.OpenIdConnectUrl = new(n.GetScalarValue(), UriKind.RelativeOrAbsolute) + (o, n, _) => + { + var connectUrl = n.GetScalarValue(); + if (connectUrl != null) + { + o.OpenIdConnectUrl = new(connectUrl, UriKind.RelativeOrAbsolute); + } + } }, { "flows", diff --git a/src/Microsoft.OpenApi/Reader/V3/OpenApiServerVariableDeserializer.cs b/src/Microsoft.OpenApi/Reader/V3/OpenApiServerVariableDeserializer.cs index 3579a40b7..5e9642df6 100644 --- a/src/Microsoft.OpenApi/Reader/V3/OpenApiServerVariableDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V3/OpenApiServerVariableDeserializer.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. using System; +using System.Linq; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Reader.ParseNodes; @@ -19,7 +20,7 @@ internal static partial class OpenApiV3Deserializer { { "enum", - (o, n, doc) => o.Enum = n.CreateSimpleList((s, p) => s.GetScalarValue(), doc) + (o, n, doc) => o.Enum = n.CreateSimpleList((s, p) => s.GetScalarValue(), doc).OfType().ToList() }, { "default", diff --git a/src/Microsoft.OpenApi/Reader/V3/OpenApiV3Deserializer.cs b/src/Microsoft.OpenApi/Reader/V3/OpenApiV3Deserializer.cs index 45559a029..29eb3db70 100644 --- a/src/Microsoft.OpenApi/Reader/V3/OpenApiV3Deserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V3/OpenApiV3Deserializer.cs @@ -21,7 +21,7 @@ namespace Microsoft.OpenApi.Reader.V3 internal static partial class OpenApiV3Deserializer { private static void ParseMap( - MapNode mapNode, + MapNode? mapNode, T domainObject, FixedFieldMap fixedFieldMap, PatternFieldMap patternFieldMap, @@ -72,38 +72,6 @@ private static void ProcessAnyFields( } } - private static void ProcessAnyListFields( - MapNode mapNode, - T domainObject, - AnyListFieldMap anyListFieldMap) - { - foreach (var anyListFieldName in anyListFieldMap.Keys.ToList()) - { - try - { - var newProperty = new List(); - - mapNode.Context.StartObject(anyListFieldName); - - foreach (var propertyElement in anyListFieldMap[anyListFieldName].PropertyGetter(domainObject)) - { - newProperty.Add(propertyElement); - } - - anyListFieldMap[anyListFieldName].PropertySetter(domainObject, newProperty); - } - catch (OpenApiException exception) - { - exception.Pointer = mapNode.Context.GetLocation(); - mapNode.Context.Diagnostic.Errors.Add(new(exception)); - } - finally - { - mapNode.Context.EndObject(); - } - } - } - private static void ProcessAnyMapFields( MapNode mapNode, T domainObject, @@ -114,18 +82,23 @@ private static void ProcessAnyMapFields( try { mapNode.Context.StartObject(anyMapFieldName); - - foreach (var propertyMapElement in anyMapFieldMap[anyMapFieldName].PropertyMapGetter(domainObject)) + var mapElements = anyMapFieldMap[anyMapFieldName].PropertyMapGetter(domainObject); + if (mapElements is not null) { - mapNode.Context.StartObject(propertyMapElement.Key); - - if (propertyMapElement.Value != null) + foreach (var propertyMapElement in mapElements) { - var any = anyMapFieldMap[anyMapFieldName].PropertyGetter(propertyMapElement.Value); - - anyMapFieldMap[anyMapFieldName].PropertySetter(propertyMapElement.Value, any); + mapNode.Context.StartObject(propertyMapElement.Key); + + if (propertyMapElement.Value != null) + { + var any = anyMapFieldMap[anyMapFieldName].PropertyGetter(propertyMapElement.Value); + if (any is not null) + { + anyMapFieldMap[anyMapFieldName].PropertySetter(propertyMapElement.Value, any); + } + } } - } + } } catch (OpenApiException exception) { @@ -139,12 +112,6 @@ private static void ProcessAnyMapFields( } } - private static RuntimeExpression LoadRuntimeExpression(ParseNode node) - { - var value = node.GetScalarValue(); - return RuntimeExpression.Build(value); - } - private static RuntimeExpressionAnyWrapper LoadRuntimeExpressionAnyWrapper(ParseNode node) { var value = node.GetScalarValue(); @@ -171,7 +138,7 @@ public static OpenApiAny LoadAny(ParseNode node, OpenApiDocument hostDocument) private static IOpenApiExtension LoadExtension(string name, ParseNode node) { - if (node.Context.ExtensionParsers.TryGetValue(name, out var parser) && parser( + if (node.Context.ExtensionParsers is not null && node.Context.ExtensionParsers.TryGetValue(name, out var parser) && parser( node.CreateAny(), OpenApiSpecVersion.OpenApi3_0) is { } result) { return result; @@ -182,23 +149,22 @@ private static IOpenApiExtension LoadExtension(string name, ParseNode node) } } - private static string LoadString(ParseNode node) + private static string? LoadString(ParseNode node) { return node.GetScalarValue(); } - private static (string, string) GetReferenceIdAndExternalResource(string pointer) + private static (string, string?) GetReferenceIdAndExternalResource(string pointer) { var refSegments = pointer.Split('/'); - var refId = refSegments.Last(); - var isExternalResource = !refSegments.First().StartsWith("#", StringComparison.OrdinalIgnoreCase); - - string externalResource = null; + var refId = refSegments[refSegments.Count() -1]; + var isExternalResource = !refSegments[0].StartsWith("#", StringComparison.OrdinalIgnoreCase); + + string? externalResource = null; if (isExternalResource) { externalResource = pointer.Split('#')[0].TrimEnd('#'); } - return (refId, externalResource); } } diff --git a/src/Microsoft.OpenApi/Reader/V3/OpenApiV3VersionService.cs b/src/Microsoft.OpenApi/Reader/V3/OpenApiV3VersionService.cs index 612c59dfb..d568b327c 100644 --- a/src/Microsoft.OpenApi/Reader/V3/OpenApiV3VersionService.cs +++ b/src/Microsoft.OpenApi/Reader/V3/OpenApiV3VersionService.cs @@ -65,111 +65,6 @@ public OpenApiV3VersionService(OpenApiDiagnostic diagnostic) [typeof(OpenApiXml)] = OpenApiV3Deserializer.LoadXml }; - /// - /// Parse the string to a object. - /// - /// The URL of the reference - /// The type of object referenced based on the context of the reference - /// - /// - public OpenApiReference ConvertToOpenApiReference( - string reference, - ReferenceType? type, - string summary = null, - string description = null) - { - if (!string.IsNullOrWhiteSpace(reference)) - { - var segments = reference.Split('#'); - if (segments.Length == 1) - { - if (type is ReferenceType.Tag or ReferenceType.SecurityScheme) - { - return new() - { - Type = type, - Id = reference - }; - } - - // Either this is an external reference as an entire file - // or a simple string-style reference for tag and security scheme. - return new() - { - Type = type, - ExternalResource = segments[0] - }; - } - else if (segments.Length == 2) - { - if (reference.StartsWith("#", StringComparison.OrdinalIgnoreCase)) - { - // "$ref": "#/components/schemas/Pet" - try - { - return ParseLocalReference(segments[1]); - } - catch (OpenApiException ex) - { - Diagnostic.Errors.Add(new(ex)); - } - } - // Where fragments point into a non-OpenAPI document, the id will be the complete fragment identifier - var id = segments[1]; - var isFragment = false; - - // $ref: externalSource.yaml#/Pet - if (id.StartsWith("/components/", StringComparison.Ordinal)) - { - var localSegments = segments[1].Split('/'); - localSegments[2].TryGetEnumFromDisplayName(out var referencedType); - if (type == null) - { - type = referencedType; - } - else - { - if (type != referencedType) - { - throw new OpenApiException("Referenced type mismatch"); - } - } - id = localSegments[3]; - } - else if (id.StartsWith("/paths/", StringComparison.Ordinal)) - { - var localSegments = segments[1].Split(_pathSeparator, StringSplitOptions.RemoveEmptyEntries); - if (localSegments.Length == 2) - { - // The reference of a path may contain JSON escape character ~1 for the forward-slash character, replace this otherwise - // the reference cannot be resolved. - id = localSegments[1].Replace("~1", "/"); - } - else - { - throw new OpenApiException("Referenced Path mismatch"); - } - } - else - { - isFragment = true; - } - - var openApiReference = new OpenApiReference - { - ExternalResource = segments[0], - Type = type, - Id = id, - IsFragment = isFragment, - }; - - return openApiReference; - } - } - - throw new OpenApiException(string.Format(SRResource.ReferenceHasInvalidFormat, reference)); - } - public OpenApiDocument LoadDocument(RootNode rootNode) { return OpenApiV3Deserializer.LoadOpenApi(rootNode); @@ -181,7 +76,7 @@ public T LoadElement(ParseNode node, OpenApiDocument doc) where T : IOpenApiE } /// - public string GetReferenceScalarValues(MapNode mapNode, string scalarValue) + public string? GetReferenceScalarValues(MapNode mapNode, string scalarValue) { if (mapNode.Any(static x => !"$ref".Equals(x.Name, StringComparison.OrdinalIgnoreCase)) && mapNode @@ -193,36 +88,6 @@ public string GetReferenceScalarValues(MapNode mapNode, string scalarValue) } return null; - } - - private OpenApiReference ParseLocalReference(string localReference) - { - if (string.IsNullOrWhiteSpace(localReference)) - { - throw new ArgumentException(string.Format(SRResource.ArgumentNullOrWhiteSpace, nameof(localReference))); - } - - var segments = localReference.Split('/'); - - if (segments.Length == 4 && segments[1] == "components") // /components/{type}/pet - { - segments[2].TryGetEnumFromDisplayName(out var referenceType); - var refId = segments[3]; - if (segments[2] == "pathItems") - { - refId = "/" + segments[3]; - } - - var parsedReference = new OpenApiReference - { - Type = referenceType, - Id = refId - }; - - return parsedReference; - } - - throw new OpenApiException(string.Format(SRResource.ReferenceHasInvalidFormat, localReference)); - } + } } } diff --git a/src/Microsoft.OpenApi/Reader/V3/OpenApiXmlDeserializer.cs b/src/Microsoft.OpenApi/Reader/V3/OpenApiXmlDeserializer.cs index 43245338d..e6bc2c836 100644 --- a/src/Microsoft.OpenApi/Reader/V3/OpenApiXmlDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V3/OpenApiXmlDeserializer.cs @@ -22,7 +22,14 @@ internal static partial class OpenApiV3Deserializer }, { "namespace", - (o, n, _) => o.Namespace = new(n.GetScalarValue(), UriKind.Absolute) + (o, n, _) => + { + var value = n.GetScalarValue(); + if (value != null) + { + o.Namespace = new(value, UriKind.Absolute); + } + } }, { "prefix", @@ -30,11 +37,25 @@ internal static partial class OpenApiV3Deserializer }, { "attribute", - (o, n, _) => o.Attribute = bool.Parse(n.GetScalarValue()) + (o, n, _) => + { + var attribute = n.GetScalarValue(); + if (attribute is not null) + { + o.Attribute = bool.Parse(attribute); + } + } }, { "wrapped", - (o, n, _) => o.Wrapped = bool.Parse(n.GetScalarValue()) + (o, n, _) => + { + var wrapped = n.GetScalarValue(); + if (wrapped is not null) + { + o.Wrapped = bool.Parse(wrapped); + } + } }, }; diff --git a/src/Microsoft.OpenApi/Reader/V31/OpenApiContactDeserializer.cs b/src/Microsoft.OpenApi/Reader/V31/OpenApiContactDeserializer.cs index be487e434..138eafe70 100644 --- a/src/Microsoft.OpenApi/Reader/V31/OpenApiContactDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V31/OpenApiContactDeserializer.cs @@ -26,9 +26,14 @@ internal static partial class OpenApiV31Deserializer } }, { - "url", (o, n, _) => + "url", + (o, n, t) => { - o.Url = new Uri(n.GetScalarValue(), UriKind.RelativeOrAbsolute); + var url = n.GetScalarValue(); + if (url != null) + { + o.Url = new(url, UriKind.RelativeOrAbsolute); + } } }, }; diff --git a/src/Microsoft.OpenApi/Reader/V31/OpenApiDiscriminatorDeserializer.cs b/src/Microsoft.OpenApi/Reader/V31/OpenApiDiscriminatorDeserializer.cs index 0302149f6..e94f408d2 100644 --- a/src/Microsoft.OpenApi/Reader/V31/OpenApiDiscriminatorDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V31/OpenApiDiscriminatorDeserializer.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Reader.ParseNodes; @@ -23,7 +24,7 @@ internal static partial class OpenApiV31Deserializer { "mapping", (o, n, _) => { - o.Mapping = n.CreateSimpleMap(LoadString); + o.Mapping = n.CreateSimpleMap(LoadString).Where(kv => kv.Value is not null).ToDictionary(kv => kv.Key, kv => kv.Value!); } } }; diff --git a/src/Microsoft.OpenApi/Reader/V31/OpenApiDocumentDeserializer.cs b/src/Microsoft.OpenApi/Reader/V31/OpenApiDocumentDeserializer.cs index ae95f58e4..0abe92234 100644 --- a/src/Microsoft.OpenApi/Reader/V31/OpenApiDocumentDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V31/OpenApiDocumentDeserializer.cs @@ -44,7 +44,7 @@ public static OpenApiDocument LoadOpenApi(RootNode rootNode) ParseMap(openApiNode, openApiDoc, _openApiFixedFields, _openApiPatternFields, openApiDoc); // Register components - openApiDoc.Workspace.RegisterComponents(openApiDoc); + openApiDoc.Workspace?.RegisterComponents(openApiDoc); return openApiDoc; } diff --git a/src/Microsoft.OpenApi/Reader/V31/OpenApiEncodingDeserializer.cs b/src/Microsoft.OpenApi/Reader/V31/OpenApiEncodingDeserializer.cs index d571a42d0..5272f6495 100644 --- a/src/Microsoft.OpenApi/Reader/V31/OpenApiEncodingDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V31/OpenApiEncodingDeserializer.cs @@ -38,13 +38,21 @@ internal static partial class OpenApiV31Deserializer { "explode", (o, n, _) => { - o.Explode = bool.Parse(n.GetScalarValue()); + var explode = n.GetScalarValue(); + if (explode is not null) + { + o.Explode = bool.Parse(explode); + } } }, { "allowedReserved", (o, n, _) => { - o.AllowReserved = bool.Parse(n.GetScalarValue()); + var allowReserved = n.GetScalarValue(); + if (allowReserved is not null) + { + o.AllowReserved = bool.Parse(allowReserved); + } } }, }; diff --git a/src/Microsoft.OpenApi/Reader/V31/OpenApiExternalDocsDeserializer.cs b/src/Microsoft.OpenApi/Reader/V31/OpenApiExternalDocsDeserializer.cs index a5b06efff..75d9c89a1 100644 --- a/src/Microsoft.OpenApi/Reader/V31/OpenApiExternalDocsDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V31/OpenApiExternalDocsDeserializer.cs @@ -22,9 +22,14 @@ internal static partial class OpenApiV31Deserializer } }, { - "url", (o, n, _) => + "url", + (o, n, t) => { - o.Url = new Uri(n.GetScalarValue(), UriKind.RelativeOrAbsolute); + var url = n.GetScalarValue(); + if (url != null) + { + o.Url = new(url, UriKind.RelativeOrAbsolute); + } } }, }; diff --git a/src/Microsoft.OpenApi/Reader/V31/OpenApiHeaderDeserializer.cs b/src/Microsoft.OpenApi/Reader/V31/OpenApiHeaderDeserializer.cs index 2c23c70a4..3c01a56a2 100644 --- a/src/Microsoft.OpenApi/Reader/V31/OpenApiHeaderDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V31/OpenApiHeaderDeserializer.cs @@ -22,27 +22,47 @@ internal static partial class OpenApiV31Deserializer } }, { - "required", (o, n, _) => + "required", + (o, n, _) => { - o.Required = bool.Parse(n.GetScalarValue()); + var required = n.GetScalarValue(); + if (required != null) + { + o.Required = bool.Parse(required); + } } }, { - "deprecated", (o, n, _) => + "deprecated", + (o, n, _) => { - o.Deprecated = bool.Parse(n.GetScalarValue()); + var deprecated = n.GetScalarValue(); + if (deprecated != null) + { + o.Deprecated = bool.Parse(deprecated); + } } }, { - "allowEmptyValue", (o, n, _) => + "allowEmptyValue", + (o, n, _) => { - o.AllowEmptyValue = bool.Parse(n.GetScalarValue()); + var allowEmptyVal = n.GetScalarValue(); + if (allowEmptyVal != null) + { + o.AllowEmptyValue = bool.Parse(allowEmptyVal); + } } }, { - "allowReserved", (o, n, _) => + "allowReserved", + (o, n, _) => { - o.AllowReserved = bool.Parse(n.GetScalarValue()); + var allowReserved = n.GetScalarValue(); + if (allowReserved != null) + { + o.AllowReserved = bool.Parse(allowReserved); + } } }, { @@ -56,9 +76,14 @@ internal static partial class OpenApiV31Deserializer } }, { - "explode", (o, n, _) => + "explode", + (o, n, _) => { - o.Explode = bool.Parse(n.GetScalarValue()); + var explode = n.GetScalarValue(); + if (explode != null) + { + o.Explode = bool.Parse(explode); + } } }, { diff --git a/src/Microsoft.OpenApi/Reader/V31/OpenApiInfoDeserializer.cs b/src/Microsoft.OpenApi/Reader/V31/OpenApiInfoDeserializer.cs index 86597b421..49a700683 100644 --- a/src/Microsoft.OpenApi/Reader/V31/OpenApiInfoDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V31/OpenApiInfoDeserializer.cs @@ -38,9 +38,14 @@ internal static partial class OpenApiV31Deserializer } }, { - "termsOfService", (o, n, _) => + "termsOfService", + (o, n, _) => { - o.TermsOfService = new Uri(n.GetScalarValue(), UriKind.RelativeOrAbsolute); + var terms = n.GetScalarValue(); + if (terms != null) + { + o.TermsOfService = new(terms, UriKind.RelativeOrAbsolute); + } } }, { diff --git a/src/Microsoft.OpenApi/Reader/V31/OpenApiLicenseDeserializer.cs b/src/Microsoft.OpenApi/Reader/V31/OpenApiLicenseDeserializer.cs index 7ef705095..1f874d21e 100644 --- a/src/Microsoft.OpenApi/Reader/V31/OpenApiLicenseDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V31/OpenApiLicenseDeserializer.cs @@ -26,11 +26,16 @@ internal static partial class OpenApiV31Deserializer } }, { - "url", (o, n, _) => + "url", + (o, n, _) => { - o.Url = new Uri(n.GetScalarValue(), UriKind.RelativeOrAbsolute); + var url = n.GetScalarValue(); + if (url != null) + { + o.Url = new(url, UriKind.RelativeOrAbsolute); + } } - }, + } }; private static readonly PatternFieldMap _licensePatternFields = new() diff --git a/src/Microsoft.OpenApi/Reader/V31/OpenApiOAuthFlowDeserializer.cs b/src/Microsoft.OpenApi/Reader/V31/OpenApiOAuthFlowDeserializer.cs index 3efc3ef5a..ab5f29350 100644 --- a/src/Microsoft.OpenApi/Reader/V31/OpenApiOAuthFlowDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V31/OpenApiOAuthFlowDeserializer.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Reader.ParseNodes; @@ -15,24 +16,39 @@ internal static partial class OpenApiV31Deserializer new() { { - "authorizationUrl", (o, n, _) => + "authorizationUrl", + (o, n, _) => { - o.AuthorizationUrl = new Uri(n.GetScalarValue(), UriKind.RelativeOrAbsolute); + var url = n.GetScalarValue(); + if (url != null) + { + o.AuthorizationUrl = new(url, UriKind.RelativeOrAbsolute); + } } }, { - "tokenUrl", (o, n, _) => + "tokenUrl", + (o, n, _) => { - o.TokenUrl = new Uri(n.GetScalarValue(), UriKind.RelativeOrAbsolute); + var url = n.GetScalarValue(); + if (url != null) + { + o.TokenUrl = new(url, UriKind.RelativeOrAbsolute); + } } }, { - "refreshUrl", (o, n, _) => + "refreshUrl", + (o, n, _) => { - o.RefreshUrl = new Uri(n.GetScalarValue(), UriKind.RelativeOrAbsolute); + var url = n.GetScalarValue(); + if (url != null) + { + o.RefreshUrl = new(url, UriKind.RelativeOrAbsolute); + } } }, - {"scopes", (o, n, _) => o.Scopes = n.CreateSimpleMap(LoadString)} + {"scopes", (o, n, _) => o.Scopes = n.CreateSimpleMap(LoadString).Where(kv => kv.Value is not null).ToDictionary(kv => kv.Key, kv => kv.Value!)} }; private static readonly PatternFieldMap _oAuthFlowPatternFields = diff --git a/src/Microsoft.OpenApi/Reader/V31/OpenApiOperationDeserializer.cs b/src/Microsoft.OpenApi/Reader/V31/OpenApiOperationDeserializer.cs index d969cca36..cf0b4856c 100644 --- a/src/Microsoft.OpenApi/Reader/V31/OpenApiOperationDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V31/OpenApiOperationDeserializer.cs @@ -73,9 +73,14 @@ internal static partial class OpenApiV31Deserializer } }, { - "deprecated", (o, n, _) => + "deprecated", + (o, n, _) => { - o.Deprecated = bool.Parse(n.GetScalarValue()); + var deprecated = n.GetScalarValue(); + if (deprecated != null) + { + o.Deprecated = bool.Parse(deprecated); + } } }, { @@ -109,7 +114,7 @@ internal static OpenApiOperation LoadOperation(ParseNode node, OpenApiDocument h return operation; } - private static OpenApiTagReference LoadTagByReference(string tagName, OpenApiDocument hostDocument) + private static OpenApiTagReference LoadTagByReference(string tagName, OpenApiDocument? hostDocument) { var tagObject = new OpenApiTagReference(tagName, hostDocument); return tagObject; diff --git a/src/Microsoft.OpenApi/Reader/V31/OpenApiParameterDeserializer.cs b/src/Microsoft.OpenApi/Reader/V31/OpenApiParameterDeserializer.cs index 35e1308cb..eae4e4993 100644 --- a/src/Microsoft.OpenApi/Reader/V31/OpenApiParameterDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V31/OpenApiParameterDeserializer.cs @@ -39,27 +39,47 @@ internal static partial class OpenApiV31Deserializer } }, { - "required", (o, n, _) => + "required", + (o, n, t) => { - o.Required = bool.Parse(n.GetScalarValue()); + var required = n.GetScalarValue(); + if (required != null) + { + o.Required = bool.Parse(required); + } } }, { - "deprecated", (o, n, _) => + "deprecated", + (o, n, t) => { - o.Deprecated = bool.Parse(n.GetScalarValue()); + var deprecated = n.GetScalarValue(); + if (deprecated != null) + { + o.Deprecated = bool.Parse(deprecated); + } } }, { - "allowEmptyValue", (o, n, _) => + "allowEmptyValue", + (o, n, t) => { - o.AllowEmptyValue = bool.Parse(n.GetScalarValue()); + var allowEmptyValue = n.GetScalarValue(); + if (allowEmptyValue != null) + { + o.AllowEmptyValue = bool.Parse(allowEmptyValue); + } } }, { - "allowReserved", (o, n, _) => + "allowReserved", + (o, n, _) => { - o.AllowReserved = bool.Parse(n.GetScalarValue()); + var allowReserved = n.GetScalarValue(); + if (allowReserved != null) + { + o.AllowReserved = bool.Parse(allowReserved); + } } }, { @@ -75,7 +95,11 @@ internal static partial class OpenApiV31Deserializer { "explode", (o, n, _) => { - o.Explode = bool.Parse(n.GetScalarValue()); + var explode = n.GetScalarValue(); + if (explode != null) + { + o.Explode = bool.Parse(explode); + } } }, { diff --git a/src/Microsoft.OpenApi/Reader/V31/OpenApiRequestBodyDeserializer.cs b/src/Microsoft.OpenApi/Reader/V31/OpenApiRequestBodyDeserializer.cs index fe786aa44..ef08b1b2b 100644 --- a/src/Microsoft.OpenApi/Reader/V31/OpenApiRequestBodyDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V31/OpenApiRequestBodyDeserializer.cs @@ -31,7 +31,11 @@ internal static partial class OpenApiV31Deserializer { "required", (o, n, _) => { - o.Required = bool.Parse(n.GetScalarValue()); + var required = n.GetScalarValue(); + if (required != null) + { + o.Required = bool.Parse(required); + } } }, }; diff --git a/src/Microsoft.OpenApi/Reader/V31/OpenApiSchemaDeserializer.cs b/src/Microsoft.OpenApi/Reader/V31/OpenApiSchemaDeserializer.cs index 4be2a4b5d..717a6e68f 100644 --- a/src/Microsoft.OpenApi/Reader/V31/OpenApiSchemaDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V31/OpenApiSchemaDeserializer.cs @@ -35,7 +35,7 @@ internal static partial class OpenApiV31Deserializer }, { "$vocabulary", - (o, n, _) => o.Vocabulary = n.CreateSimpleMap(LoadBool) + (o, n, _) => o.Vocabulary = n.CreateSimpleMap(LoadBool).ToDictionary(kvp => kvp.Key, kvp => kvp.Value ?? false) }, { "$dynamicRef", @@ -49,13 +49,27 @@ internal static partial class OpenApiV31Deserializer "$defs", (o, n, t) => o.Definitions = n.CreateMap(LoadSchema, t) }, - { + { "multipleOf", - (o, n, _) => o.MultipleOf = decimal.Parse(n.GetScalarValue(), NumberStyles.Float, CultureInfo.InvariantCulture) + (o, n, _) => + { + var multipleOf = n.GetScalarValue(); + if (multipleOf != null) + { + o.MultipleOf = decimal.Parse(multipleOf, NumberStyles.Float, CultureInfo.InvariantCulture); + } + } }, { "maximum", - (o, n, _) => o.Maximum = ParserHelper.ParseDecimalWithFallbackOnOverflow(n.GetScalarValue(), decimal.MaxValue) + (o, n,_) => + { + var max = n.GetScalarValue(); + if (max != null) + { + o.Maximum = ParserHelper.ParseDecimalWithFallbackOnOverflow(max, decimal.MaxValue); + } + } }, { "exclusiveMaximum", @@ -63,7 +77,14 @@ internal static partial class OpenApiV31Deserializer }, { "minimum", - (o, n, _) => o.Minimum = ParserHelper.ParseDecimalWithFallbackOnOverflow(n.GetScalarValue(), decimal.MinValue) + (o, n, _) => + { + var min = n.GetScalarValue(); + if (min != null) + { + o.Minimum = ParserHelper.ParseDecimalWithFallbackOnOverflow(min, decimal.MinValue); + } + } }, { "exclusiveMinimum", @@ -71,11 +92,25 @@ internal static partial class OpenApiV31Deserializer }, { "maxLength", - (o, n, _) => o.MaxLength = int.Parse(n.GetScalarValue(), CultureInfo.InvariantCulture) + (o, n, _) => + { + var maxLength = n.GetScalarValue(); + if (maxLength != null) + { + o.MaxLength = int.Parse(maxLength, CultureInfo.InvariantCulture); + } + } }, { "minLength", - (o, n, _) => o.MinLength = int.Parse(n.GetScalarValue(), CultureInfo.InvariantCulture) + (o, n, _) => + { + var minLength = n.GetScalarValue(); + if (minLength != null) + { + o.MinLength = int.Parse(minLength, CultureInfo.InvariantCulture); + } + } }, { "pattern", @@ -83,31 +118,73 @@ internal static partial class OpenApiV31Deserializer }, { "maxItems", - (o, n, _) => o.MaxItems = int.Parse(n.GetScalarValue(), CultureInfo.InvariantCulture) + (o, n, _) => + { + var maxItems = n.GetScalarValue(); + if (maxItems != null) + { + o.MaxItems = int.Parse(maxItems, CultureInfo.InvariantCulture); + } + } }, { "minItems", - (o, n, _) => o.MinItems = int.Parse(n.GetScalarValue(), CultureInfo.InvariantCulture) + (o, n, _) => + { + var minItems = n.GetScalarValue(); + if (minItems != null) + { + o.MinItems = int.Parse(minItems, CultureInfo.InvariantCulture); + } + } }, { "uniqueItems", - (o, n, _) => o.UniqueItems = bool.Parse(n.GetScalarValue()) + (o, n, _) => + { + var uniqueItems = n.GetScalarValue(); + if (uniqueItems != null) + { + o.UniqueItems = bool.Parse(uniqueItems); + } + } }, { "unevaluatedProperties", - (o, n, _) => o.UnevaluatedProperties = bool.Parse(n.GetScalarValue()) + (o, n, _) => + { + var unevaluatedProps = n.GetScalarValue(); + if (unevaluatedProps != null) + { + o.UnevaluatedProperties = bool.Parse(unevaluatedProps); + } + } }, { "maxProperties", - (o, n, _) => o.MaxProperties = int.Parse(n.GetScalarValue(), CultureInfo.InvariantCulture) + (o, n, _) => + { + var maxProps = n.GetScalarValue(); + if (maxProps != null) + { + o.MaxProperties = int.Parse(maxProps, CultureInfo.InvariantCulture); + } + } }, { "minProperties", - (o, n, _) => o.MinProperties = int.Parse(n.GetScalarValue(), CultureInfo.InvariantCulture) + (o, n, _) => + { + var minProps = n.GetScalarValue(); + if (minProps != null) + { + o.MinProperties = int.Parse(minProps, CultureInfo.InvariantCulture); + } + } }, { "required", - (o, n, doc) => o.Required = new HashSet(n.CreateSimpleList((n2, p) => n2.GetScalarValue(), doc)) + (o, n, doc) => o.Required = new HashSet(n.CreateSimpleList((n2, p) => n2.GetScalarValue(), doc).Where(s => s != null)) }, { "enum", @@ -119,7 +196,7 @@ internal static partial class OpenApiV31Deserializer { if (n is ValueNode) { - o.Type = n.GetScalarValue().ToJsonSchemaType(); + o.Type = n.GetScalarValue()?.ToJsonSchemaType(); } else { @@ -127,8 +204,11 @@ internal static partial class OpenApiV31Deserializer JsonSchemaType combinedType = 0; foreach(var type in list) { - var schemaType = type.ToJsonSchemaType(); - combinedType |= schemaType; + if (type is not null) + { + var schemaType = type.ToJsonSchemaType(); + combinedType |= schemaType; + } } o.Type = combinedType; } @@ -171,7 +251,11 @@ internal static partial class OpenApiV31Deserializer { if (n is ValueNode) { - o.AdditionalPropertiesAllowed = bool.Parse(n.GetScalarValue()); + var value = n.GetScalarValue(); + if (value is not null) + { + o.AdditionalPropertiesAllowed = bool.Parse(value); + } } else { @@ -195,10 +279,14 @@ internal static partial class OpenApiV31Deserializer "nullable", (o, n, _) => { - var nullable = bool.Parse(n.GetScalarValue()); - if (nullable) // if nullable, convert type into an array of type(s) and null + var value = n.GetScalarValue(); + if (value is not null) { - o.Type |= JsonSchemaType.Null; + var nullable = bool.Parse(value); + if (nullable) // if nullable, convert type into an array of type(s) and null + { + o.Type |= JsonSchemaType.Null; + } } } }, @@ -208,11 +296,25 @@ internal static partial class OpenApiV31Deserializer }, { "readOnly", - (o, n, _) => o.ReadOnly = bool.Parse(n.GetScalarValue()) + (o, n, _) => + { + var readOnly = n.GetScalarValue(); + if (readOnly != null) + { + o.ReadOnly = bool.Parse(readOnly); + } + } }, { "writeOnly", - (o, n, _) => o.WriteOnly = bool.Parse(n.GetScalarValue()) + (o, n, _) => + { + var writeOnly = n.GetScalarValue(); + if (writeOnly != null) + { + o.WriteOnly = bool.Parse(writeOnly); + } + } }, { "xml", @@ -232,7 +334,14 @@ internal static partial class OpenApiV31Deserializer }, { "deprecated", - (o, n, _) => o.Deprecated = bool.Parse(n.GetScalarValue()) + (o, n, t) => + { + var deprecated = n.GetScalarValue(); + if (deprecated != null) + { + o.Deprecated = bool.Parse(deprecated); + } + } }, { "dependentRequired", @@ -273,13 +382,13 @@ public static IOpenApiSchema LoadSchema(ParseNode node, OpenApiDocument hostDocu { propertyNode.ParseField(schema, _openApiSchemaFixedFields, _openApiSchemaPatternFields, hostDocument); } - else + else if (schema.UnrecognizedKeywords is not null && propertyNode.JsonNode is not null) { schema.UnrecognizedKeywords[propertyNode.Name] = propertyNode.JsonNode; } } - if (schema.Extensions.ContainsKey(OpenApiConstants.NullableExtension)) + if (schema.Extensions is not null && schema.Extensions.ContainsKey(OpenApiConstants.NullableExtension)) { var type = schema.Type; schema.Type = type | JsonSchemaType.Null; diff --git a/src/Microsoft.OpenApi/Reader/V31/OpenApiSecurityRequirementDeserializer.cs b/src/Microsoft.OpenApi/Reader/V31/OpenApiSecurityRequirementDeserializer.cs index cddb97699..fda3551d2 100644 --- a/src/Microsoft.OpenApi/Reader/V31/OpenApiSecurityRequirementDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V31/OpenApiSecurityRequirementDeserializer.cs @@ -1,6 +1,7 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. +using System.Linq; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.Interfaces; using Microsoft.OpenApi.Models.References; @@ -24,8 +25,9 @@ public static OpenApiSecurityRequirement LoadSecurityRequirement(ParseNode node, { var scheme = LoadSecuritySchemeByReference(property.Name, hostDocument); - var scopes = property.Value.CreateSimpleList((value, p) => value.GetScalarValue(), hostDocument); - + var scopes = property.Value.CreateSimpleList((n2, p) => n2.GetScalarValue(), hostDocument) + .OfType() + .ToList(); if (scheme != null) { securityRequirement.Add(scheme, scopes); @@ -40,7 +42,7 @@ public static OpenApiSecurityRequirement LoadSecurityRequirement(ParseNode node, return securityRequirement; } - private static OpenApiSecuritySchemeReference LoadSecuritySchemeByReference(string schemeName, OpenApiDocument hostDocument) + private static OpenApiSecuritySchemeReference LoadSecuritySchemeByReference(string schemeName, OpenApiDocument? hostDocument) { return new OpenApiSecuritySchemeReference(schemeName, hostDocument); } diff --git a/src/Microsoft.OpenApi/Reader/V31/OpenApiSecuritySchemeDeserializer.cs b/src/Microsoft.OpenApi/Reader/V31/OpenApiSecuritySchemeDeserializer.cs index 2189f1179..54136f669 100644 --- a/src/Microsoft.OpenApi/Reader/V31/OpenApiSecuritySchemeDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V31/OpenApiSecuritySchemeDeserializer.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System; @@ -66,7 +66,11 @@ internal static partial class OpenApiV31Deserializer { "openIdConnectUrl", (o, n, _) => { - o.OpenIdConnectUrl = new Uri(n.GetScalarValue(), UriKind.RelativeOrAbsolute); + var connectUrl = n.GetScalarValue(); + if (connectUrl != null) + { + o.OpenIdConnectUrl = new(connectUrl, UriKind.RelativeOrAbsolute); + } } }, { diff --git a/src/Microsoft.OpenApi/Reader/V31/OpenApiServerVariableDeserializer.cs b/src/Microsoft.OpenApi/Reader/V31/OpenApiServerVariableDeserializer.cs index a3aaa141a..46181ed62 100644 --- a/src/Microsoft.OpenApi/Reader/V31/OpenApiServerVariableDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V31/OpenApiServerVariableDeserializer.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. using System; +using System.Linq; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Reader.ParseNodes; @@ -20,7 +21,7 @@ internal static partial class OpenApiV31Deserializer { "enum", (o, n, doc) => { - o.Enum = n.CreateSimpleList((s, p) => s.GetScalarValue(), doc); + o.Enum = n.CreateSimpleList((s, p) => s.GetScalarValue(), doc).OfType().ToList(); } }, { diff --git a/src/Microsoft.OpenApi/Reader/V31/OpenApiV31Deserializer.cs b/src/Microsoft.OpenApi/Reader/V31/OpenApiV31Deserializer.cs index f9f3b168e..4ecb26bf7 100644 --- a/src/Microsoft.OpenApi/Reader/V31/OpenApiV31Deserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V31/OpenApiV31Deserializer.cs @@ -20,11 +20,11 @@ namespace Microsoft.OpenApi.Reader.V31 internal static partial class OpenApiV31Deserializer { private static void ParseMap( - MapNode mapNode, + MapNode? mapNode, T domainObject, - FixedFieldMap fixedFieldMap, + FixedFieldMap fixedFieldMap, PatternFieldMap patternFieldMap, - OpenApiDocument doc = null) + OpenApiDocument doc) { if (mapNode == null) { @@ -92,8 +92,10 @@ private static void ProcessAnyMapFields( if (propertyMapElement.Value != null) { var any = anyMapFieldMap[anyMapFieldName].PropertyGetter(propertyMapElement.Value); - - anyMapFieldMap[anyMapFieldName].PropertySetter(propertyMapElement.Value, any); + if (any is not null) + { + anyMapFieldMap[anyMapFieldName].PropertySetter(propertyMapElement.Value, any); + } } } } @@ -135,22 +137,23 @@ public static JsonNode LoadAny(ParseNode node, OpenApiDocument hostDocument) private static IOpenApiExtension LoadExtension(string name, ParseNode node) { - return node.Context.ExtensionParsers.TryGetValue(name, out var parser) + return node.Context.ExtensionParsers is not null && node.Context.ExtensionParsers.TryGetValue(name, out var parser) ? parser(node.CreateAny(), OpenApiSpecVersion.OpenApi3_1) : new OpenApiAny(node.CreateAny()); } - private static string LoadString(ParseNode node) + private static string? LoadString(ParseNode node) { return node.GetScalarValue(); } - private static bool LoadBool(ParseNode node) + private static bool? LoadBool(ParseNode node) { - return bool.Parse(node.GetScalarValue()); + var value = node.GetScalarValue(); + return value is not null ? bool.Parse(value) : null; } - private static (string, string) GetReferenceIdAndExternalResource(string pointer) + private static (string, string?) GetReferenceIdAndExternalResource(string pointer) { /* Check whether the reference pointer is a URL * (id keyword allows you to supply a URL for the schema as a target for referencing) @@ -159,10 +162,10 @@ private static (string, string) GetReferenceIdAndExternalResource(string pointer * E.g. $ref: '#/components/schemas/pet' */ var refSegments = pointer.Split('/'); - string refId = !pointer.Contains('#') ? pointer : refSegments.Last(); + string refId = !pointer.Contains('#') ? pointer : refSegments[refSegments.Count()-1]; - var isExternalResource = !refSegments.First().StartsWith("#", StringComparison.OrdinalIgnoreCase); - string externalResource = null; + var isExternalResource = !refSegments[0].StartsWith("#", StringComparison.OrdinalIgnoreCase); + string? externalResource = null; if (isExternalResource && pointer.Contains('#')) { externalResource = pointer.Split('#')[0].TrimEnd('#'); diff --git a/src/Microsoft.OpenApi/Reader/V31/OpenApiV31VersionService.cs b/src/Microsoft.OpenApi/Reader/V31/OpenApiV31VersionService.cs index bfaa82051..bb6cac930 100644 --- a/src/Microsoft.OpenApi/Reader/V31/OpenApiV31VersionService.cs +++ b/src/Microsoft.OpenApi/Reader/V31/OpenApiV31VersionService.cs @@ -64,95 +64,6 @@ public OpenApiV31VersionService(OpenApiDiagnostic diagnostic) [typeof(OpenApiXml)] = OpenApiV31Deserializer.LoadXml }; - /// - /// Parse the string to a object. - /// - /// The URL of the reference - /// The type of object refefenced based on the context of the reference - /// The summary of the reference - /// A reference description - public OpenApiReference ConvertToOpenApiReference( - string reference, - ReferenceType? type, - string summary = null, - string description = null) - { - if (!string.IsNullOrWhiteSpace(reference)) - { - var segments = reference.Split('#'); - if (segments.Length == 1) - { - if (type == ReferenceType.Tag || type == ReferenceType.SecurityScheme) - { - return new OpenApiReference - { - Summary = summary, - Description = description, - Type = type, - Id = reference - }; - } - - // Either this is an external reference as an entire file - // or a simple string-style reference for tag and security scheme. - return new OpenApiReference - { - Summary = summary, - Description = description, - Type = type, - ExternalResource = segments[0] - }; - } - else if (segments.Length == 2) - { - if (reference.StartsWith("#", StringComparison.OrdinalIgnoreCase)) - { - // "$ref": "#/components/schemas/Pet" - try - { - return ParseLocalReference(segments[1], summary, description); - } - catch (OpenApiException ex) - { - Diagnostic.Errors.Add(new OpenApiError(ex)); - return null; - } - } - // Where fragments point into a non-OpenAPI document, the id will be the complete fragment identifier - string id = segments[1]; - // $ref: externalSource.yaml#/Pet - if (id.StartsWith("/components/", StringComparison.Ordinal)) - { - var localSegments = segments[1].Split('/'); - localSegments[2].TryGetEnumFromDisplayName(out var referencedType); - if (type == null) - { - type = referencedType; - } - else - { - if (type != referencedType) - { - throw new OpenApiException("Referenced type mismatch"); - } - } - id = localSegments[3]; - } - - return new OpenApiReference - { - Summary = summary, - Description = description, - ExternalResource = segments[0], - Type = type, - Id = id - }; - } - } - - throw new OpenApiException(string.Format(SRResource.ReferenceHasInvalidFormat, reference)); - } - public OpenApiDocument LoadDocument(RootNode rootNode) { return OpenApiV31Deserializer.LoadOpenApi(rootNode); @@ -164,7 +75,7 @@ public T LoadElement(ParseNode node, OpenApiDocument doc) where T : IOpenApiE } /// - public string GetReferenceScalarValues(MapNode mapNode, string scalarValue) + public string? GetReferenceScalarValues(MapNode mapNode, string scalarValue) { if (mapNode.Any(static x => !"$ref".Equals(x.Name, StringComparison.OrdinalIgnoreCase))) { @@ -176,37 +87,5 @@ public string GetReferenceScalarValues(MapNode mapNode, string scalarValue) return null; } - - private OpenApiReference ParseLocalReference(string localReference, string summary = null, string description = null) - { - if (string.IsNullOrWhiteSpace(localReference)) - { - throw new ArgumentException(string.Format(SRResource.ArgumentNullOrWhiteSpace, nameof(localReference))); - } - - var segments = localReference.Split('/'); - - if (segments.Length == 4 && segments[1] == "components") // /components/{type}/pet - { - segments[2].TryGetEnumFromDisplayName(out var referenceType); - var refId = segments[3]; - if (segments[2] == "pathItems") - { - refId = "/" + segments[3]; - } - - var parsedReference = new OpenApiReference - { - Summary = summary, - Description = description, - Type = referenceType, - Id = refId - }; - - return parsedReference; - } - - throw new OpenApiException(string.Format(SRResource.ReferenceHasInvalidFormat, localReference)); - } } } diff --git a/src/Microsoft.OpenApi/Reader/V31/OpenApiXmlDeserializer.cs b/src/Microsoft.OpenApi/Reader/V31/OpenApiXmlDeserializer.cs index 0f821e9d2..c2776c52a 100644 --- a/src/Microsoft.OpenApi/Reader/V31/OpenApiXmlDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V31/OpenApiXmlDeserializer.cs @@ -23,29 +23,42 @@ internal static partial class OpenApiV31Deserializer } }, { - "namespace", (o, n, _) => + "namespace", + (o, n, _) => { - o.Namespace = new Uri(n.GetScalarValue(), UriKind.Absolute); + var value = n.GetScalarValue(); + if (value != null) + { + o.Namespace = new(value, UriKind.Absolute); + } } }, { - "prefix", (o, n, _) => - { - o.Prefix = n.GetScalarValue(); - } + "prefix", + (o, n, _) => o.Prefix = n.GetScalarValue() }, { - "attribute", (o, n, _) => + "attribute", + (o, n, _) => { - o.Attribute = bool.Parse(n.GetScalarValue()); + var attribute = n.GetScalarValue(); + if (attribute is not null) + { + o.Attribute = bool.Parse(attribute); + } } }, { - "wrapped", (o, n, _) => + "wrapped", + (o, n, _) => { - o.Wrapped = bool.Parse(n.GetScalarValue()); + var wrapped = n.GetScalarValue(); + if (wrapped is not null) + { + o.Wrapped = bool.Parse(wrapped); + } } - }, + } }; private static readonly PatternFieldMap _xmlPatternFields = diff --git a/src/Microsoft.OpenApi/Services/CopyReferences.cs b/src/Microsoft.OpenApi/Services/CopyReferences.cs index ab0ad8e31..6874b3f8d 100644 --- a/src/Microsoft.OpenApi/Services/CopyReferences.cs +++ b/src/Microsoft.OpenApi/Services/CopyReferences.cs @@ -19,61 +19,61 @@ public override void Visit(IOpenApiReferenceHolder referenceHolder) switch (referenceHolder) { case OpenApiSchemaReference openApiSchemaReference: - AddSchemaToComponents(openApiSchemaReference.Target, openApiSchemaReference.Reference.Id); + AddSchemaToComponents(openApiSchemaReference.Target, openApiSchemaReference.Reference?.Id); break; case OpenApiSchema schema: AddSchemaToComponents(schema); break; case OpenApiParameterReference openApiParameterReference: - AddParameterToComponents(openApiParameterReference.Target, openApiParameterReference.Reference.Id); + AddParameterToComponents(openApiParameterReference.Target, openApiParameterReference.Reference?.Id); break; case OpenApiParameter parameter: AddParameterToComponents(parameter); break; case OpenApiResponseReference openApiResponseReference: - AddResponseToComponents(openApiResponseReference.Target, openApiResponseReference.Reference.Id); + AddResponseToComponents(openApiResponseReference.Target, openApiResponseReference.Reference?.Id); break; case OpenApiResponse response: AddResponseToComponents(response); break; case OpenApiRequestBodyReference openApiRequestBodyReference: - AddRequestBodyToComponents(openApiRequestBodyReference.Target, openApiRequestBodyReference.Reference.Id); + AddRequestBodyToComponents(openApiRequestBodyReference.Target, openApiRequestBodyReference.Reference?.Id); break; case OpenApiRequestBody requestBody: AddRequestBodyToComponents(requestBody); break; case OpenApiExampleReference openApiExampleReference: - AddExampleToComponents(openApiExampleReference.Target, openApiExampleReference.Reference.Id); + AddExampleToComponents(openApiExampleReference.Target, openApiExampleReference.Reference?.Id); break; case OpenApiExample example: AddExampleToComponents(example); break; case OpenApiHeaderReference openApiHeaderReference: - AddHeaderToComponents(openApiHeaderReference.Target, openApiHeaderReference.Reference.Id); + AddHeaderToComponents(openApiHeaderReference.Target, openApiHeaderReference.Reference?.Id); break; case OpenApiHeader header: AddHeaderToComponents(header); break; case OpenApiCallbackReference openApiCallbackReference: - AddCallbackToComponents(openApiCallbackReference.Target, openApiCallbackReference.Reference.Id); + AddCallbackToComponents(openApiCallbackReference.Target, openApiCallbackReference.Reference?.Id); break; case OpenApiCallback callback: AddCallbackToComponents(callback); break; case OpenApiLinkReference openApiLinkReference: - AddLinkToComponents(openApiLinkReference.Target, openApiLinkReference.Reference.Id); + AddLinkToComponents(openApiLinkReference.Target, openApiLinkReference.Reference?.Id); break; case OpenApiLink link: AddLinkToComponents(link); break; case OpenApiSecuritySchemeReference openApiSecuritySchemeReference: - AddSecuritySchemeToComponents(openApiSecuritySchemeReference.Target, openApiSecuritySchemeReference.Reference.Id); + AddSecuritySchemeToComponents(openApiSecuritySchemeReference.Target, openApiSecuritySchemeReference.Reference?.Id); break; case OpenApiSecurityScheme securityScheme: AddSecuritySchemeToComponents(securityScheme); break; case OpenApiPathItemReference openApiPathItemReference: - AddPathItemToComponents(openApiPathItemReference.Target, openApiPathItemReference.Reference.Id); + AddPathItemToComponents(openApiPathItemReference.Target, openApiPathItemReference.Reference?.Id); break; case OpenApiPathItem pathItem: AddPathItemToComponents(pathItem); @@ -85,94 +85,94 @@ public override void Visit(IOpenApiReferenceHolder referenceHolder) base.Visit(referenceHolder); } - private void AddSchemaToComponents(IOpenApiSchema schema, string referenceId = null) + private void AddSchemaToComponents(IOpenApiSchema? schema, string? referenceId = null) { EnsureComponentsExist(); EnsureSchemasExist(); - if (!Components.Schemas.ContainsKey(referenceId)) + if (Components.Schemas is not null && referenceId is not null && schema is not null && !Components.Schemas.ContainsKey(referenceId)) { Components.Schemas.Add(referenceId, schema); } } - private void AddParameterToComponents(IOpenApiParameter parameter, string referenceId = null) + private void AddParameterToComponents(IOpenApiParameter? parameter, string? referenceId = null) { EnsureComponentsExist(); EnsureParametersExist(); - if (!Components.Parameters.ContainsKey(referenceId)) + if (Components.Parameters is not null && parameter is not null && referenceId is not null && !Components.Parameters.ContainsKey(referenceId)) { Components.Parameters.Add(referenceId, parameter); } } - private void AddResponseToComponents(IOpenApiResponse response, string referenceId = null) + private void AddResponseToComponents(IOpenApiResponse? response, string? referenceId = null) { EnsureComponentsExist(); EnsureResponsesExist(); - if (!Components.Responses.ContainsKey(referenceId)) + if (Components.Responses is not null && referenceId is not null && response is not null && !Components.Responses.ContainsKey(referenceId)) { Components.Responses.Add(referenceId, response); } } - private void AddRequestBodyToComponents(IOpenApiRequestBody requestBody, string referenceId = null) + private void AddRequestBodyToComponents(IOpenApiRequestBody? requestBody, string? referenceId = null) { EnsureComponentsExist(); EnsureRequestBodiesExist(); - if (!Components.RequestBodies.ContainsKey(referenceId)) + if (Components.RequestBodies is not null && requestBody is not null && referenceId is not null && !Components.RequestBodies.ContainsKey(referenceId)) { Components.RequestBodies.Add(referenceId, requestBody); } } - private void AddLinkToComponents(IOpenApiLink link, string referenceId = null) + private void AddLinkToComponents(IOpenApiLink? link, string? referenceId = null) { EnsureComponentsExist(); EnsureLinksExist(); - if (!Components.Links.ContainsKey(referenceId)) + if (Components.Links is not null && link is not null && referenceId is not null && !Components.Links.ContainsKey(referenceId)) { Components.Links.Add(referenceId, link); } } - private void AddCallbackToComponents(IOpenApiCallback callback, string referenceId = null) + private void AddCallbackToComponents(IOpenApiCallback? callback, string? referenceId = null) { EnsureComponentsExist(); EnsureCallbacksExist(); - if (!Components.Callbacks.ContainsKey(referenceId)) + if (Components.Callbacks is not null && callback is not null && referenceId is not null && !Components.Callbacks.ContainsKey(referenceId)) { Components.Callbacks.Add(referenceId, callback); } } - private void AddHeaderToComponents(IOpenApiHeader header, string referenceId = null) + private void AddHeaderToComponents(IOpenApiHeader? header, string? referenceId = null) { EnsureComponentsExist(); EnsureHeadersExist(); - if (!Components.Headers.ContainsKey(referenceId)) + if (Components.Headers is not null && header is not null && referenceId is not null && !Components.Headers.ContainsKey(referenceId)) { Components.Headers.Add(referenceId, header); } } - private void AddExampleToComponents(IOpenApiExample example, string referenceId = null) + private void AddExampleToComponents(IOpenApiExample? example, string? referenceId = null) { EnsureComponentsExist(); EnsureExamplesExist(); - if (!Components.Examples.ContainsKey(referenceId)) + if (Components.Examples is not null && example is not null && referenceId is not null && !Components.Examples.ContainsKey(referenceId)) { Components.Examples.Add(referenceId, example); } } - private void AddPathItemToComponents(IOpenApiPathItem pathItem, string referenceId = null) + private void AddPathItemToComponents(IOpenApiPathItem? pathItem, string? referenceId = null) { EnsureComponentsExist(); EnsurePathItemsExist(); - if (!Components.PathItems.ContainsKey(referenceId)) + if (Components.PathItems is not null && pathItem is not null && referenceId is not null && !Components.PathItems.ContainsKey(referenceId)) { Components.PathItems.Add(referenceId, pathItem); } } - private void AddSecuritySchemeToComponents(IOpenApiSecurityScheme securityScheme, string referenceId = null) + private void AddSecuritySchemeToComponents(IOpenApiSecurityScheme? securityScheme, string? referenceId = null) { EnsureComponentsExist(); EnsureSecuritySchemesExist(); - if (!Components.SecuritySchemes.ContainsKey(referenceId)) + if (Components.SecuritySchemes is not null && securityScheme is not null && referenceId is not null && !Components.SecuritySchemes.ContainsKey(referenceId)) { Components.SecuritySchemes.Add(referenceId, securityScheme); } @@ -184,7 +184,7 @@ public override void Visit(IOpenApiSchema schema) // This is needed to handle schemas used in Responses in components if (schema is OpenApiSchemaReference openApiSchemaReference) { - AddSchemaToComponents(openApiSchemaReference.Target, openApiSchemaReference.Reference.Id); + AddSchemaToComponents(openApiSchemaReference.Target, openApiSchemaReference.Reference?.Id); } base.Visit(schema); } @@ -196,50 +196,80 @@ private void EnsureComponentsExist() private void EnsureSchemasExist() { - _target.Components.Schemas ??= new Dictionary(); + if (_target.Components is not null) + { + _target.Components.Schemas ??= new Dictionary(); + } } private void EnsureParametersExist() { - _target.Components.Parameters ??= new Dictionary(); + if (_target.Components is not null) + { + _target.Components.Parameters ??= new Dictionary(); + } } private void EnsureResponsesExist() { - _target.Components.Responses ??= new Dictionary(); + if (_target.Components is not null) + { + _target.Components.Responses ??= new Dictionary(); + } } private void EnsureRequestBodiesExist() { - _target.Components.RequestBodies ??= new Dictionary(); + if (_target.Components is not null) + { + _target.Components.RequestBodies ??= new Dictionary(); + } } private void EnsureExamplesExist() { - _target.Components.Examples ??= new Dictionary(); + if (_target.Components is not null) + { + _target.Components.Examples ??= new Dictionary(); + } } private void EnsureHeadersExist() { - _target.Components.Headers ??= new Dictionary(); + if (_target.Components is not null) + { + _target.Components.Headers ??= new Dictionary(); + } } private void EnsureCallbacksExist() { - _target.Components.Callbacks ??= new Dictionary(); + if (_target.Components is not null) + { + _target.Components.Callbacks ??= new Dictionary(); + } } private void EnsureLinksExist() { - _target.Components.Links ??= new Dictionary(); + if (_target.Components is not null) + { + _target.Components.Links ??= new Dictionary(); + } } private void EnsureSecuritySchemesExist() { - _target.Components.SecuritySchemes ??= new Dictionary(); + if (_target.Components is not null) + { + _target.Components.SecuritySchemes ??= new Dictionary(); + } } private void EnsurePathItemsExist() { - _target.Components.PathItems ??= new Dictionary(); + if (_target.Components is not null) + { + _target.Components.PathItems = new Dictionary(); + } } } diff --git a/src/Microsoft.OpenApi/Services/LoopDetector.cs b/src/Microsoft.OpenApi/Services/LoopDetector.cs index 904361f97..dd9c0919f 100644 --- a/src/Microsoft.OpenApi/Services/LoopDetector.cs +++ b/src/Microsoft.OpenApi/Services/LoopDetector.cs @@ -20,7 +20,7 @@ public bool PushLoop(T key) _loopStacks.Add(typeof(T), stack); } - if (!stack.Contains(key)) + if (key is not null && !stack.Contains(key)) { stack.Push(key); return true; @@ -48,7 +48,10 @@ public void SaveLoop(T loop) { Loops[typeof(T)] = new(); } - Loops[typeof(T)].Add(loop); + if (loop is not null) + { + Loops[typeof(T)].Add(loop); + } } /// diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs index b17195c3b..82a09c249 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs @@ -27,10 +27,10 @@ public static class OpenApiFilterService /// The input OpenAPI document. /// A predicate. public static Func CreatePredicate( - string operationIds = null, - string tags = null, - Dictionary> requestUrls = null, - OpenApiDocument source = null) + string? operationIds = null, + string? tags = null, + Dictionary>? requestUrls = null, + OpenApiDocument? source = null) { Func predicate; ValidateFilters(requestUrls, operationIds, tags); @@ -42,7 +42,7 @@ public static Func CreatePredicate( { predicate = GetTagsPredicate(tags); } - else if (requestUrls != null) + else if (requestUrls != null && source is not null) { predicate = GetRequestUrlsPredicate(requestUrls, source); } @@ -88,36 +88,39 @@ public static OpenApiDocument CreateFilteredDocument(OpenApiDocument source, Fun var results = FindOperations(source, predicate); foreach (var result in results) { - IOpenApiPathItem pathItem; - var pathKey = result.CurrentKeys.Path; + IOpenApiPathItem? pathItem = null; + var pathKey = result.CurrentKeys?.Path; if (subset.Paths == null) { subset.Paths = new(); pathItem = new OpenApiPathItem(); - subset.Paths.Add(pathKey, pathItem); + if (pathKey is not null) + { + subset.Paths.Add(pathKey, pathItem); + } } else { - if (!subset.Paths.TryGetValue(pathKey, out pathItem)) + if (pathKey is not null && !subset.Paths.TryGetValue(pathKey, out pathItem)) { pathItem = new OpenApiPathItem(); subset.Paths.Add(pathKey, pathItem); } } - if (result.CurrentKeys.Operation != null) + if (result.CurrentKeys?.Operation != null && result.Operation != null) { - pathItem.Operations.Add(result.CurrentKeys.Operation, result.Operation); + pathItem?.Operations?.Add(result.CurrentKeys.Operation, result.Operation); if (result.Parameters?.Any() ?? false) { foreach (var parameter in result.Parameters) { - if (!pathItem.Parameters.Contains(parameter)) + if (pathItem?.Parameters is not null && !pathItem.Parameters.Contains(parameter)) { pathItem.Parameters.Add(parameter); - } + } } } } @@ -148,7 +151,7 @@ public static OpenApiUrlTreeNode CreateOpenApiUrlTreeNode(Dictionary GetOpenApiOperations(OpenApiUrlTreeNode rootNode, string relativeUrl, string label) + private static IDictionary? GetOpenApiOperations(OpenApiUrlTreeNode rootNode, string relativeUrl, string label) { if (relativeUrl.Equals("/", StringComparison.Ordinal) && rootNode.HasOperations(label)) { @@ -157,7 +160,7 @@ private static IDictionary GetOpenApiOperations(Op var urlSegments = relativeUrl.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries); - IDictionary operations = null; + IDictionary? operations = null; var targetChild = rootNode; @@ -247,93 +250,120 @@ private static void CopyReferences(OpenApiDocument target) } while (morestuff); } - private static bool AddReferences(OpenApiComponents newComponents, OpenApiComponents target) + private static bool AddReferences(OpenApiComponents newComponents, OpenApiComponents? target) { var moreStuff = false; - foreach (var item in newComponents.Schemas) + if (newComponents.Schemas is not null) { - if (!target.Schemas.ContainsKey(item.Key)) + foreach (var item in newComponents.Schemas) { - moreStuff = true; - target.Schemas.Add(item); + if (target?.Schemas is not null && !target.Schemas.ContainsKey(item.Key)) + { + moreStuff = true; + target.Schemas.Add(item); + } } } - foreach (var item in newComponents.Parameters) + if (newComponents.Parameters is not null) { - if (!target.Parameters.ContainsKey(item.Key)) + foreach (var item in newComponents.Parameters) { - moreStuff = true; - target.Parameters.Add(item); + if (target?.Parameters is not null && !target.Parameters.ContainsKey(item.Key)) + { + moreStuff = true; + target.Parameters.Add(item); + } } } - foreach (var item in newComponents.Responses) + if (newComponents.Responses is not null) { - if (!target.Responses.ContainsKey(item.Key)) + foreach (var item in newComponents.Responses) { - moreStuff = true; - target.Responses.Add(item); + if (target?.Responses is not null && !target.Responses.ContainsKey(item.Key)) + { + moreStuff = true; + target.Responses.Add(item); + } } } - foreach (var item in newComponents.RequestBodies - .Where(item => !target.RequestBodies.ContainsKey(item.Key))) + if (newComponents.RequestBodies is not null) { - moreStuff = true; - target.RequestBodies.Add(item); + foreach (var item in newComponents.RequestBodies + .Where(item => target?.RequestBodies is not null && !target.RequestBodies.ContainsKey(item.Key))) + { + moreStuff = true; + target?.RequestBodies?.Add(item); + } } - foreach (var item in newComponents.Headers - .Where(item => !target.Headers.ContainsKey(item.Key))) + if (newComponents.Headers is not null) { - moreStuff = true; - target.Headers.Add(item); + foreach (var item in newComponents.Headers + .Where(item => target?.Headers is not null && !target.Headers.ContainsKey(item.Key))) + { + moreStuff = true; + target?.Headers?.Add(item); + } } - foreach (var item in newComponents.Links - .Where(item => !target.Links.ContainsKey(item.Key))) + if (newComponents.Links is not null) { - moreStuff = true; - target.Links.Add(item); + foreach (var item in newComponents.Links + .Where(item => target?.Links is not null && !target.Links.ContainsKey(item.Key))) + { + moreStuff = true; + target?.Links?.Add(item); + } } - foreach (var item in newComponents.Callbacks - .Where(item => !target.Callbacks.ContainsKey(item.Key))) + if (newComponents.Callbacks is not null) { - moreStuff = true; - target.Callbacks.Add(item); + foreach (var item in newComponents.Callbacks + .Where(item => target?.Callbacks is not null && !target.Callbacks.ContainsKey(item.Key))) + { + moreStuff = true; + target?.Callbacks?.Add(item); + } } - foreach (var item in newComponents.Examples - .Where(item => !target.Examples.ContainsKey(item.Key))) + if (newComponents.Examples is not null) { - moreStuff = true; - target.Examples.Add(item); + foreach (var item in newComponents.Examples + .Where(item => target?.Examples is not null && !target.Examples.ContainsKey(item.Key))) + { + moreStuff = true; + target?.Examples?.Add(item); + } } - foreach (var item in newComponents.SecuritySchemes - .Where(item => !target.SecuritySchemes.ContainsKey(item.Key))) + if (newComponents.SecuritySchemes is not null) { - moreStuff = true; - target.SecuritySchemes.Add(item); + foreach (var item in newComponents.SecuritySchemes + .Where(item => target?.SecuritySchemes is not null && !target.SecuritySchemes.ContainsKey(item.Key))) + { + moreStuff = true; + target?.SecuritySchemes?.Add(item); + } } return moreStuff; } - private static string ExtractPath(string url, IList serverList) + private static string ExtractPath(string url, IList? serverList) { // if OpenAPI has servers, then see if the url matches one of them - var baseUrl = serverList.Select(s => s.Url.TrimEnd('/')) - .FirstOrDefault(c => url.Contains(c)); + var baseUrl = serverList?.Select(s => s.Url?.TrimEnd('/')) + .FirstOrDefault(c => c != null && url.Contains(c)); return baseUrl == null ? new Uri(new(SRResource.DefaultBaseUri), url).GetComponents(UriComponents.Path | UriComponents.KeepDelimiter, UriFormat.Unescaped) : url.Split(new[] { baseUrl }, StringSplitOptions.None)[1]; } - private static void ValidateFilters(IDictionary> requestUrls, string operationIds, string tags) + private static void ValidateFilters(IDictionary>? requestUrls, string? operationIds, string? tags) { if (requestUrls != null && (operationIds != null || tags != null)) { @@ -364,7 +394,7 @@ private static Func GetTagsPredicate if (tagsArray.Length == 1) { var regex = new Regex(tagsArray[0]); - return (_, _, operation) => operation.Tags?.Any(tag => regex.IsMatch(tag.Name)) ?? false; + return (_, _, operation) => operation.Tags?.Any(tag => tag.Name is not null && regex.IsMatch(tag.Name)) ?? false; } else { @@ -378,22 +408,25 @@ private static Func GetRequestUrlsPr if (source != null) { var apiVersion = source.Info.Version; - var sources = new Dictionary { { apiVersion, source } }; - var rootNode = CreateOpenApiUrlTreeNode(sources); - - // Iterate through urls dictionary and fetch operations for each url - foreach (var url in requestUrls) + if (apiVersion is not null) { - var serverList = source.Servers; - var path = ExtractPath(url.Key, serverList); - var openApiOperations = GetOpenApiOperations(rootNode, path, apiVersion); - if (openApiOperations == null) + var sources = new Dictionary { { apiVersion, source } }; + var rootNode = CreateOpenApiUrlTreeNode(sources); + + // Iterate through urls dictionary and fetch operations for each url + foreach (var url in requestUrls) { - Debug.WriteLine($"The url {url.Key} could not be found in the OpenApi description"); - continue; + var serverList = source.Servers; + var path = ExtractPath(url.Key, serverList); + var openApiOperations = GetOpenApiOperations(rootNode, path, apiVersion); + if (openApiOperations == null) + { + Debug.WriteLine($"The url {url.Key} could not be found in the OpenApi description"); + continue; + } + operationTypes.AddRange(GetOperationTypes(openApiOperations, url.Value, path)); } - operationTypes.AddRange(GetOperationTypes(openApiOperations, url.Value, path)); - } + } } if (!operationTypes.Any()) diff --git a/src/Microsoft.OpenApi/Services/OpenApiReferenceError.cs b/src/Microsoft.OpenApi/Services/OpenApiReferenceError.cs index 6dfd066ff..c9e3eda78 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiReferenceError.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiReferenceError.cs @@ -14,7 +14,7 @@ public class OpenApiReferenceError : OpenApiError /// /// The reference that caused the error. /// - public readonly OpenApiReference Reference; + public readonly OpenApiReference? Reference; /// /// Initializes the class using the message and pointer from the given exception. /// diff --git a/src/Microsoft.OpenApi/Services/OpenApiUrlTreeNode.cs b/src/Microsoft.OpenApi/Services/OpenApiUrlTreeNode.cs index 8a61772dd..ab1a33e0b 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiUrlTreeNode.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiUrlTreeNode.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System; @@ -93,7 +93,7 @@ public static OpenApiUrlTreeNode Create(OpenApiDocument doc, string label) var root = Create(); - var paths = doc.Paths; + var paths = doc?.Paths; if (paths != null) { foreach (var path in paths) @@ -283,7 +283,9 @@ private static void ProcessNode(OpenApiUrlTreeNode node, TextWriter writer) private static string GetMethods(OpenApiUrlTreeNode node) { - return String.Join("_", node.PathItems.SelectMany(p => p.Value.Operations.Select(o => o.Key)) + return String.Join("_", node.PathItems + .Where(p => p.Value.Operations != null) + .SelectMany(p => p.Value.Operations!.Select(o => o.Key)) .Distinct() .Select(o => o.ToString().ToUpper()) .OrderBy(o => o) diff --git a/src/Microsoft.OpenApi/Services/OpenApiWalker.cs b/src/Microsoft.OpenApi/Services/OpenApiWalker.cs index b9b053c96..cf07356d3 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiWalker.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiWalker.cs @@ -36,7 +36,7 @@ public OpenApiWalker(OpenApiVisitorBase visitor) /// Visits list of and child objects /// /// OpenApiDocument to be walked - public void Walk(OpenApiDocument doc) + public void Walk(OpenApiDocument? doc) { if (doc == null) { @@ -62,7 +62,7 @@ public void Walk(OpenApiDocument doc) /// /// Visits list of and child objects /// - internal void Walk(ISet tags) + internal void Walk(ISet? tags) { if (tags == null) { @@ -85,7 +85,7 @@ internal void Walk(ISet tags) /// /// Visits list of and child objects /// - internal void Walk(ISet tags) + internal void Walk(ISet? tags) { if (tags == null) { @@ -121,7 +121,7 @@ internal void Walk(string externalDocs) /// /// Visits and child objects /// - internal void Walk(OpenApiExternalDocs externalDocs) + internal void Walk(OpenApiExternalDocs? externalDocs) { if (externalDocs == null) { @@ -285,7 +285,7 @@ internal void Walk(OpenApiPaths paths) /// /// Visits Webhooks and child objects /// - internal void Walk(IDictionary webhooks) + internal void Walk(IDictionary? webhooks) { if (webhooks == null) { @@ -303,13 +303,13 @@ internal void Walk(IDictionary webhooks) Walk(pathItem.Key, () => Walk(pathItem.Value));// JSON Pointer uses ~1 as an escape character for / _visitor.CurrentKeys.Path = null; } - }; + } } /// /// Visits list of and child objects /// - internal void Walk(IList servers) + internal void Walk(IList? servers) { if (servers == null) { @@ -350,7 +350,7 @@ internal void Walk(OpenApiInfo info) /// /// Visits dictionary of extensions /// - internal void Walk(IOpenApiExtensible openApiExtensible) + internal void Walk(IOpenApiExtensible? openApiExtensible) { if (openApiExtensible == null) { @@ -386,7 +386,7 @@ internal void Walk(IOpenApiExtension extension) /// /// Visits and child objects /// - internal void Walk(OpenApiLicense license) + internal void Walk(OpenApiLicense? license) { if (license == null) { @@ -399,7 +399,7 @@ internal void Walk(OpenApiLicense license) /// /// Visits and child objects /// - internal void Walk(OpenApiContact contact) + internal void Walk(OpenApiContact? contact) { if (contact == null) { @@ -427,7 +427,7 @@ internal void Walk(IOpenApiCallback callback, bool isComponent = false) _visitor.Visit(callback); - if (callback != null) + if (callback.PathItems != null) { foreach (var item in callback.PathItems) { @@ -450,7 +450,10 @@ internal void Walk(OpenApiTag tag) } _visitor.Visit(tag); - _visitor.Visit(tag.ExternalDocs); + if (tag.ExternalDocs != null) + { + _visitor.Visit(tag.ExternalDocs); + } _visitor.Visit(tag as IOpenApiExtensible); } @@ -473,7 +476,7 @@ internal void Walk(OpenApiTagReference tag) /// /// Visits and child objects /// - internal void Walk(OpenApiServer server) + internal void Walk(OpenApiServer? server) { if (server == null) { @@ -488,7 +491,7 @@ internal void Walk(OpenApiServer server) /// /// Visits dictionary of /// - internal void Walk(IDictionary serverVariables) + internal void Walk(IDictionary? serverVariables) { if (serverVariables == null) { @@ -554,15 +557,18 @@ internal void Walk(IOpenApiPathItem pathItem, bool isComponent = false) Walk(OpenApiConstants.Parameters, () => Walk(pathItem.Parameters)); Walk(pathItem.Operations); } - _visitor.Visit(pathItem as IOpenApiExtensible); + if (pathItem is IOpenApiExtensible extensiblePathItem) + { + _visitor.Visit(extensiblePathItem); + } _pathItemLoop.Pop(); } /// /// Visits dictionary of /// - internal void Walk(IDictionary operations) + internal void Walk(IDictionary? operations) { if (operations == null) { @@ -606,7 +612,7 @@ internal void Walk(OpenApiOperation operation) /// /// Visits list of /// - internal void Walk(IList securityRequirements) + internal void Walk(IList? securityRequirements) { if (securityRequirements == null) { @@ -627,7 +633,7 @@ internal void Walk(IList securityRequirements) /// /// Visits list of /// - internal void Walk(IList parameters) + internal void Walk(IList? parameters) { if (parameters == null) { @@ -672,7 +678,7 @@ internal void Walk(IOpenApiParameter parameter, bool isComponent = false) /// /// Visits and child objects /// - internal void Walk(OpenApiResponses responses) + internal void Walk(OpenApiResponses? responses) { if (responses == null) { @@ -719,7 +725,7 @@ internal void Walk(IOpenApiResponse response, bool isComponent = false) /// /// Visits and child objects /// - internal void Walk(IOpenApiRequestBody requestBody, bool isComponent = false) + internal void Walk(IOpenApiRequestBody? requestBody, bool isComponent = false) { if (requestBody == null) { @@ -744,7 +750,7 @@ internal void Walk(IOpenApiRequestBody requestBody, bool isComponent = false) /// /// Visits dictionary of /// - internal void Walk(IDictionary headers) + internal void Walk(IDictionary? headers) { if (headers == null) { @@ -766,7 +772,7 @@ internal void Walk(IDictionary headers) /// /// Visits dictionary of /// - internal void Walk(IDictionary callbacks) + internal void Walk(IDictionary? callbacks) { if (callbacks == null) { @@ -788,7 +794,7 @@ internal void Walk(IDictionary callbacks) /// /// Visits dictionary of /// - internal void Walk(IDictionary content) + internal void Walk(IDictionary? content) { if (content == null) { @@ -828,7 +834,7 @@ internal void Walk(OpenApiMediaType mediaType) /// /// Visits dictionary of /// - internal void Walk(IDictionary encodings) + internal void Walk(IDictionary? encodings) { if (encodings == null) { @@ -870,7 +876,7 @@ internal void Walk(OpenApiEncoding encoding) /// /// Visits and child objects /// - internal void Walk(IOpenApiSchema schema, bool isComponent = false) + internal void Walk(IOpenApiSchema? schema, bool isComponent = false) { if (schema == null || schema is IOpenApiReferenceHolder holder && ProcessAsReference(holder, isComponent)) { @@ -940,7 +946,7 @@ internal void Walk(IOpenApiSchema schema, bool isComponent = false) /// /// Visits dictionary of /// - internal void Walk(IDictionary examples) + internal void Walk(IDictionary? examples) { if (examples == null) { @@ -963,7 +969,7 @@ internal void Walk(IDictionary examples) /// /// Visits and child objects /// - internal void Walk(JsonNode example) + internal void Walk(JsonNode? example) { if (example == null) { @@ -1065,7 +1071,7 @@ internal void Walk(OpenApiOAuthFlow oAuthFlow) /// /// Visits dictionary of and child objects /// - internal void Walk(IDictionary links) + internal void Walk(IDictionary? links) { if (links == null) { @@ -1258,56 +1264,56 @@ public class CurrentKeys /// /// Current Path key /// - public string Path { get; set; } + public string? Path { get; set; } /// /// Current Operation Type /// - public HttpMethod Operation { get; set; } + public HttpMethod? Operation { get; set; } /// /// Current Response Status Code /// - public string Response { get; set; } + public string? Response { get; set; } /// /// Current Content Media Type /// - public string Content { get; set; } + public string? Content { get; set; } /// /// Current Callback Key /// - public string Callback { get; set; } + public string? Callback { get; set; } /// /// Current Link Key /// - public string Link { get; set; } + public string? Link { get; set; } /// /// Current Header Key /// - public string Header { get; internal set; } + public string? Header { get; internal set; } /// /// Current Encoding Key /// - public string Encoding { get; internal set; } + public string? Encoding { get; internal set; } /// /// Current Example Key /// - public string Example { get; internal set; } + public string? Example { get; internal set; } /// /// Current Extension Key /// - public string Extension { get; internal set; } + public string? Extension { get; internal set; } /// /// Current ServerVariable /// - public string ServerVariable { get; internal set; } + public string? ServerVariable { get; internal set; } } } diff --git a/src/Microsoft.OpenApi/Services/OpenApiWorkspace.cs b/src/Microsoft.OpenApi/Services/OpenApiWorkspace.cs index ec368a6c0..d668626db 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiWorkspace.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiWorkspace.cs @@ -23,7 +23,7 @@ public class OpenApiWorkspace /// /// The base location from where all relative references are resolved /// - public Uri BaseUrl { get; } + public Uri? BaseUrl { get; } /// /// Initialize workspace pointing to a base URL to allow resolving relative document locations. Use a file:// url to point to a folder @@ -69,78 +69,107 @@ public void RegisterComponents(OpenApiDocument document) string location; // Register Schema - foreach (var item in document.Components.Schemas) + if (document.Components.Schemas != null) { - location = item.Value.Id ?? baseUri + ReferenceType.Schema.GetDisplayName() + ComponentSegmentSeparator + item.Key; - - RegisterComponent(location, item.Value); + foreach (var item in document.Components.Schemas) + { + location = item.Value.Id ?? baseUri + ReferenceType.Schema.GetDisplayName() + ComponentSegmentSeparator + item.Key; + RegisterComponent(location, item.Value); + } } // Register Parameters - foreach (var item in document.Components.Parameters) + if (document.Components.Parameters != null) { - location = baseUri + ReferenceType.Parameter.GetDisplayName() + ComponentSegmentSeparator + item.Key; - RegisterComponent(location, item.Value); + foreach (var item in document.Components.Parameters) + { + location = baseUri + ReferenceType.Parameter.GetDisplayName() + ComponentSegmentSeparator + item.Key; + RegisterComponent(location, item.Value); + } } // Register Responses - foreach (var item in document.Components.Responses) + if (document.Components.Responses != null) { - location = baseUri + ReferenceType.Response.GetDisplayName() + ComponentSegmentSeparator + item.Key; - RegisterComponent(location, item.Value); + foreach (var item in document.Components.Responses) + { + location = baseUri + ReferenceType.Response.GetDisplayName() + ComponentSegmentSeparator + item.Key; + RegisterComponent(location, item.Value); + } } // Register RequestBodies - foreach (var item in document.Components.RequestBodies) + if (document.Components.RequestBodies != null) { - location = baseUri + ReferenceType.RequestBody.GetDisplayName() + ComponentSegmentSeparator + item.Key; - RegisterComponent(location, item.Value); + foreach (var item in document.Components.RequestBodies) + { + location = baseUri + ReferenceType.RequestBody.GetDisplayName() + ComponentSegmentSeparator + item.Key; + RegisterComponent(location, item.Value); + } } // Register Links - foreach (var item in document.Components.Links) + if (document.Components.Links != null) { - location = baseUri + ReferenceType.Link.GetDisplayName() + ComponentSegmentSeparator + item.Key; - RegisterComponent(location, item.Value); + foreach (var item in document.Components.Links) + { + location = baseUri + ReferenceType.Link.GetDisplayName() + ComponentSegmentSeparator + item.Key; + RegisterComponent(location, item.Value); + } } // Register Callbacks - foreach (var item in document.Components.Callbacks) + if (document.Components.Callbacks != null) { - location = baseUri + ReferenceType.Callback.GetDisplayName() + ComponentSegmentSeparator + item.Key; - RegisterComponent(location, item.Value); + foreach (var item in document.Components.Callbacks) + { + location = baseUri + ReferenceType.Callback.GetDisplayName() + ComponentSegmentSeparator + item.Key; + RegisterComponent(location, item.Value); + } } // Register PathItems - foreach (var item in document.Components.PathItems) + if (document.Components.PathItems != null) { - location = baseUri + ReferenceType.PathItem.GetDisplayName() + ComponentSegmentSeparator + item.Key; - RegisterComponent(location, item.Value); + foreach (var item in document.Components.PathItems) + { + location = baseUri + ReferenceType.PathItem.GetDisplayName() + ComponentSegmentSeparator + item.Key; + RegisterComponent(location, item.Value); + } } // Register Examples - foreach (var item in document.Components.Examples) + if (document.Components.Examples != null) { - location = baseUri + ReferenceType.Example.GetDisplayName() + ComponentSegmentSeparator + item.Key; - RegisterComponent(location, item.Value); + foreach (var item in document.Components.Examples) + { + location = baseUri + ReferenceType.Example.GetDisplayName() + ComponentSegmentSeparator + item.Key; + RegisterComponent(location, item.Value); + } } // Register Headers - foreach (var item in document.Components.Headers) + if (document.Components.Headers != null) { - location = baseUri + ReferenceType.Header.GetDisplayName() + ComponentSegmentSeparator + item.Key; - RegisterComponent(location, item.Value); + foreach (var item in document.Components.Headers) + { + location = baseUri + ReferenceType.Header.GetDisplayName() + ComponentSegmentSeparator + item.Key; + RegisterComponent(location, item.Value); + } } // Register SecuritySchemes - foreach (var item in document.Components.SecuritySchemes) + if (document.Components.SecuritySchemes != null) { - location = baseUri + ReferenceType.SecurityScheme.GetDisplayName() + ComponentSegmentSeparator + item.Key; - RegisterComponent(location, item.Value); + foreach (var item in document.Components.SecuritySchemes) + { + location = baseUri + ReferenceType.SecurityScheme.GetDisplayName() + ComponentSegmentSeparator + item.Key; + RegisterComponent(location, item.Value); + } } } - private string getBaseUri(OpenApiDocument openApiDocument) + private static string getBaseUri(OpenApiDocument openApiDocument) { return openApiDocument.BaseUri + OpenApiConstants.ComponentsSegment; } @@ -176,7 +205,7 @@ public bool RegisterComponentForDocument(OpenApiDocument openApiDocument, T c IOpenApiExample => baseUri + ReferenceType.Example.GetDisplayName() + ComponentSegmentSeparator + id, IOpenApiHeader => baseUri + ReferenceType.Header.GetDisplayName() + ComponentSegmentSeparator + id, IOpenApiSecurityScheme => baseUri + ReferenceType.SecurityScheme.GetDisplayName() + ComponentSegmentSeparator + id, - _ => throw new ArgumentException($"Invalid component type {componentToRegister.GetType().Name}"), + _ => throw new ArgumentException($"Invalid component type {componentToRegister!.GetType().Name}"), }; return RegisterComponent(location, componentToRegister); @@ -191,22 +220,23 @@ public bool RegisterComponentForDocument(OpenApiDocument openApiDocument, T c internal bool RegisterComponent(string location, T component) { var uri = ToLocationUrl(location); - if (component is IOpenApiReferenceable referenceable) + if (uri is not null) { - if (!_IOpenApiReferenceableRegistry.ContainsKey(uri)) + if (component is IOpenApiReferenceable referenceable) { - _IOpenApiReferenceableRegistry[uri] = referenceable; - return true; + if (!_IOpenApiReferenceableRegistry.ContainsKey(uri)) + { + _IOpenApiReferenceableRegistry[uri] = referenceable; + return true; + } } - } - else if (component is Stream stream) - { - if (!_artifactsRegistry.ContainsKey(uri)) + else if (component is Stream stream && !_artifactsRegistry.ContainsKey(uri)) { _artifactsRegistry[uri] = stream; return true; } - } + return false; + } return false; } @@ -216,9 +246,9 @@ internal bool RegisterComponent(string location, T component) /// /// /// - public void AddDocumentId(string key, Uri value) + public void AddDocumentId(string? key, Uri? value) { - if (!_documentsIdRegistry.ContainsKey(key)) + if (!string.IsNullOrEmpty(key) && key is not null && value is not null && !_documentsIdRegistry.ContainsKey(key)) { _documentsIdRegistry[key] = value; } @@ -229,12 +259,13 @@ public void AddDocumentId(string key, Uri value) /// /// /// The document id of the given key. - public Uri GetDocumentId(string key) + public Uri? GetDocumentId(string? key) { - if (_documentsIdRegistry.TryGetValue(key, out var id)) + if (key is not null && _documentsIdRegistry.TryGetValue(key, out var id)) { return id; } + return null; } @@ -246,6 +277,7 @@ public Uri GetDocumentId(string key) public bool Contains(string location) { var key = ToLocationUrl(location); + if (key is null) return false; return _IOpenApiReferenceableRegistry.ContainsKey(key) || _artifactsRegistry.ContainsKey(key); } @@ -260,23 +292,30 @@ public bool Contains(string location) { if (string.IsNullOrEmpty(location)) return default; - var uri = ToLocationUrl(location); - if (_IOpenApiReferenceableRegistry.TryGetValue(uri, out var referenceableValue)) - { - return (T)referenceableValue; - } - else if (_artifactsRegistry.TryGetValue(uri, out var artifact)) + var uri = ToLocationUrl(location); + if (uri is not null) { - return (T)(object)artifact; - } + if (_IOpenApiReferenceableRegistry.TryGetValue(uri, out var referenceableValue) && referenceableValue is T referenceable) + { + return referenceable; + } + else if (_artifactsRegistry.TryGetValue(uri, out var artifact) && artifact is T artifactValue) + { + return artifactValue; + } + } return default; } #nullable restore - private Uri ToLocationUrl(string location) + private Uri? ToLocationUrl(string location) { - return new(BaseUrl, location); + if (BaseUrl is not null) + { + return new(BaseUrl, location); + } + return null; } } } diff --git a/src/Microsoft.OpenApi/Services/OperationSearch.cs b/src/Microsoft.OpenApi/Services/OperationSearch.cs index d3199f38c..ff2de5d2d 100644 --- a/src/Microsoft.OpenApi/Services/OperationSearch.cs +++ b/src/Microsoft.OpenApi/Services/OperationSearch.cs @@ -35,21 +35,24 @@ public OperationSearch(Func predicat /// public override void Visit(IOpenApiPathItem pathItem) { - foreach (var item in pathItem.Operations) + if (pathItem.Operations is not null) { - var operation = item.Value; - var operationType = item.Key; - - if (_predicate(CurrentKeys.Path, operationType, operation)) + foreach (var item in pathItem.Operations) { - _searchResults.Add(new() + var operation = item.Value; + var operationType = item.Key; + + if (CurrentKeys.Path is not null && _predicate(CurrentKeys.Path, operationType, operation)) { - Operation = operation, - Parameters = pathItem.Parameters, - CurrentKeys = CopyCurrentKeys(CurrentKeys, operationType) - }); + _searchResults.Add(new() + { + Operation = operation, + Parameters = pathItem.Parameters, + CurrentKeys = CopyCurrentKeys(CurrentKeys, operationType) + }); + } } - } + } } /// diff --git a/src/Microsoft.OpenApi/Services/SearchResult.cs b/src/Microsoft.OpenApi/Services/SearchResult.cs index 6bbeed27a..2fea9e03d 100644 --- a/src/Microsoft.OpenApi/Services/SearchResult.cs +++ b/src/Microsoft.OpenApi/Services/SearchResult.cs @@ -15,16 +15,16 @@ public class SearchResult /// /// An object containing contextual information based on where the walker is currently referencing in an OpenApiDocument. /// - public CurrentKeys CurrentKeys { get; set; } + public CurrentKeys? CurrentKeys { get; set; } /// /// An Operation object. /// - public OpenApiOperation Operation { get; set; } + public OpenApiOperation? Operation { get; set; } /// /// Parameters object /// - public IList Parameters { get; set; } + public IList? Parameters { get; set; } } } diff --git a/src/Microsoft.OpenApi/Validations/IValidationContext.cs b/src/Microsoft.OpenApi/Validations/IValidationContext.cs index 36c26baa6..c7c257c56 100644 --- a/src/Microsoft.OpenApi/Validations/IValidationContext.cs +++ b/src/Microsoft.OpenApi/Validations/IValidationContext.cs @@ -37,10 +37,5 @@ public interface IValidationContext /// Pointer to source of validation error in document /// string PathString { get; } - - /// - /// - /// - OpenApiDocument HostDocument { get; } } } diff --git a/src/Microsoft.OpenApi/Validations/OpenApiValidator.cs b/src/Microsoft.OpenApi/Validations/OpenApiValidator.cs index 734c514c3..54bd92deb 100644 --- a/src/Microsoft.OpenApi/Validations/OpenApiValidator.cs +++ b/src/Microsoft.OpenApi/Validations/OpenApiValidator.cs @@ -25,11 +25,9 @@ public class OpenApiValidator : OpenApiVisitorBase, IValidationContext /// Create a visitor that will validate an OpenAPIDocument /// /// - /// - public OpenApiValidator(ValidationRuleSet ruleSet, OpenApiDocument hostDocument = null) + public OpenApiValidator(ValidationRuleSet ruleSet) { _ruleSet = ruleSet; - HostDocument = hostDocument; } /// @@ -42,11 +40,6 @@ public OpenApiValidator(ValidationRuleSet ruleSet, OpenApiDocument hostDocument /// public IEnumerable Warnings { get => _warnings; } - /// - /// The host document used for validation. - /// - public OpenApiDocument HostDocument { get; set; } - /// /// Register an error with the validation context. /// @@ -183,7 +176,7 @@ private void Validate(T item) /// 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) + private void Validate(object? item, Type type) { if (item == null) { @@ -197,10 +190,13 @@ private void Validate(object item, Type type) } var rules = _ruleSet.FindRules(type); - foreach (var rule in rules) + if (rules is not null) { - rule.Evaluate(this, item); - } + foreach (var rule in rules) + { + rule.Evaluate(this, item); + } + } } } } diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiComponentsRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiComponentsRules.cs index bd14f93ed..80ab4e9ab 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiComponentsRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiComponentsRules.cs @@ -46,7 +46,7 @@ public static class OpenApiComponentsRules ValidateKeys(context, components.Callbacks?.Keys, "callbacks"); }); - private static void ValidateKeys(IValidationContext context, IEnumerable keys, string component) + private static void ValidateKeys(IValidationContext context, IEnumerable? keys, string component) { if (keys == null) { diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiExtensionRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiExtensionRules.cs index 545f68f85..9853acb37 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiExtensionRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiExtensionRules.cs @@ -23,12 +23,15 @@ public static class OpenApiExtensibleRules (context, item) => { context.Enter("extensions"); - foreach (var extensible in item.Extensions.Keys.Where(static x => !x.StartsWith(OpenApiConstants.ExtensionFieldNamePrefix, StringComparison.OrdinalIgnoreCase))) + if (item.Extensions is not null) { - context.CreateError(nameof(ExtensionNameMustStartWithXDash), - string.Format(SRResource.Validation_ExtensionNameMustBeginWithXDash, extensible, context.PathString)); - } - context.Exit(); + foreach (var extensible in item.Extensions.Keys.Where(static x => !x.StartsWith(OpenApiConstants.ExtensionFieldNamePrefix, StringComparison.OrdinalIgnoreCase))) + { + context.CreateError(nameof(ExtensionNameMustStartWithXDash), + string.Format(SRResource.Validation_ExtensionNameMustBeginWithXDash, extensible, context.PathString)); + } + context.Exit(); + } }); } } diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiNonDefaultRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiNonDefaultRules.cs index 03661401c..70dc7396a 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiNonDefaultRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiNonDefaultRules.cs @@ -89,9 +89,9 @@ public static class OpenApiNonDefaultRules private static void ValidateMismatchedDataType(IValidationContext context, string ruleName, - JsonNode example, - IDictionary examples, - IOpenApiSchema schema) + JsonNode? example, + IDictionary? examples, + IOpenApiSchema? schema) { // example context.Enter("example"); diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiSchemaRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiSchemaRules.cs index b954c96b6..9884d54dd 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiSchemaRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiSchemaRules.cs @@ -46,28 +46,32 @@ public static class OpenApiSchemaRules /// The parent schema. /// Adds support for polymorphism. The discriminator is an object name that is used to differentiate /// between other schemas which may satisfy the payload description. - public static bool ValidateChildSchemaAgainstDiscriminator(IOpenApiSchema schema, string discriminatorName) + public static bool ValidateChildSchemaAgainstDiscriminator(IOpenApiSchema schema, string? discriminatorName) { - if (!schema.Required?.Contains(discriminatorName) ?? false) + if (discriminatorName is not null) { - // recursively check nested schema.OneOf, schema.AnyOf or schema.AllOf and their required fields for the discriminator - if (schema.OneOf.Count != 0) + if (!schema.Required?.Contains(discriminatorName) ?? false) { - return TraverseSchemaElements(discriminatorName, schema.OneOf); - } - if (schema.AnyOf.Count != 0) - { - return TraverseSchemaElements(discriminatorName, schema.AnyOf); + // recursively check nested schema.OneOf, schema.AnyOf or schema.AllOf and their required fields for the discriminator + if (schema.OneOf?.Count != 0) + { + return TraverseSchemaElements(discriminatorName, schema.OneOf); + } + if (schema.AnyOf?.Count != 0) + { + return TraverseSchemaElements(discriminatorName, schema.AnyOf); + } + if (schema.AllOf?.Count != 0) + { + return TraverseSchemaElements(discriminatorName, schema.AllOf); + } } - if (schema.AllOf.Count != 0) + else { - return TraverseSchemaElements(discriminatorName, schema.AllOf); + return true; } - } - else - { - return true; - } + return false; + } return false; } @@ -79,20 +83,24 @@ public static bool ValidateChildSchemaAgainstDiscriminator(IOpenApiSchema schema /// between other schemas which may satisfy the payload description. /// The child schema. /// - public static bool TraverseSchemaElements(string discriminatorName, IList childSchema) + public static bool TraverseSchemaElements(string discriminatorName, IList? childSchema) { - foreach (var childItem in childSchema) + if (childSchema is not null) { - if ((!childItem.Properties?.ContainsKey(discriminatorName) ?? false) && - (!childItem.Required?.Contains(discriminatorName) ?? false)) + foreach (var childItem in childSchema) { - return ValidateChildSchemaAgainstDiscriminator(childItem, discriminatorName); - } - else - { - return true; + if ((!childItem.Properties?.ContainsKey(discriminatorName) ?? false) && + (!childItem.Required?.Contains(discriminatorName) ?? false)) + { + return ValidateChildSchemaAgainstDiscriminator(childItem, discriminatorName); + } + else + { + return true; + } } - } + return false; + } return false; } diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiServerRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiServerRules.cs index 35d4b9a25..d4ffc5429 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiServerRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiServerRules.cs @@ -29,13 +29,16 @@ public static class OpenApiServerRules context.Exit(); context.Enter("variables"); - foreach (var variable in server.Variables) + if (server.Variables is not null) { - context.Enter(variable.Key); - ValidateServerVariableRequiredFields(context, variable.Key, variable.Value); + foreach (var variable in server.Variables) + { + context.Enter(variable.Key); + ValidateServerVariableRequiredFields(context, variable.Key, variable.Value); + context.Exit(); + } context.Exit(); - } - context.Exit(); + } }); // add more rules diff --git a/src/Microsoft.OpenApi/Validations/Rules/RuleHelpers.cs b/src/Microsoft.OpenApi/Validations/Rules/RuleHelpers.cs index 71f46255f..1b4896d3a 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/RuleHelpers.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/RuleHelpers.cs @@ -45,8 +45,8 @@ public static bool IsEmailAddress(this string input) public static void ValidateDataTypeMismatch( IValidationContext context, string ruleName, - JsonNode value, - IOpenApiSchema schema) + JsonNode? value, + IOpenApiSchema? schema) { if (schema == null) { @@ -54,14 +54,14 @@ public static void ValidateDataTypeMismatch( } // convert value to JsonElement and access the ValueKind property to determine the type. - var valueKind = value.GetValueKind(); + var valueKind = value?.GetValueKind(); var type = (schema.Type & ~JsonSchemaType.Null)?.ToFirstIdentifier(); var format = schema.Format; // Before checking the type, check first if the schema allows null. // If so and the data given is also null, this is allowed for any type. - if ((schema.Type.Value & JsonSchemaType.Null) is JsonSchemaType.Null && valueKind is JsonValueKind.Null) + if (schema.Type is not null && (schema.Type.Value & JsonSchemaType.Null) is JsonSchemaType.Null && valueKind is JsonValueKind.Null) { return; } diff --git a/src/Microsoft.OpenApi/Validations/ValidationRuleSet.cs b/src/Microsoft.OpenApi/Validations/ValidationRuleSet.cs index 3e38d65b2..d09d9b566 100644 --- a/src/Microsoft.OpenApi/Validations/ValidationRuleSet.cs +++ b/src/Microsoft.OpenApi/Validations/ValidationRuleSet.cs @@ -18,9 +18,9 @@ public sealed class ValidationRuleSet { private Dictionary> _rulesDictionary = new(); - private static ValidationRuleSet _defaultRuleSet; + private static ValidationRuleSet? _defaultRuleSet; - private List _emptyRules = new(); + private readonly List _emptyRules = new(); /// @@ -62,10 +62,7 @@ public IList FindRules(Type type) public static ValidationRuleSet GetDefaultRuleSet() { // Reflection can be an expensive operation, so we cache the default rule set that has already been built. - if (_defaultRuleSet == null) - { - _defaultRuleSet = BuildDefaultRuleSet(); - } + _defaultRuleSet ??= BuildDefaultRuleSet(); // We create a new instance of ValidationRuleSet per call as a safeguard // against unintentional modification of the private _defaultRuleSet. @@ -219,7 +216,7 @@ public void Remove(string ruleName) /// true if the rule is successfully removed; otherwise, false. public bool Remove(Type key, ValidationRule rule) { - if (_rulesDictionary.TryGetValue(key, out IList validationRules)) + if (_rulesDictionary.TryGetValue(key, out IList? validationRules)) { return validationRules.Remove(rule); } @@ -263,7 +260,7 @@ public bool ContainsKey(Type key) /// public bool Contains(Type key, ValidationRule rule) { - return _rulesDictionary.TryGetValue(key, out IList validationRules) && validationRules.Contains(rule); + return _rulesDictionary.TryGetValue(key, out IList? validationRules) && validationRules.Contains(rule); } /// @@ -274,7 +271,7 @@ public bool Contains(Type key, ValidationRule rule) /// key is found; otherwise, an empty object. /// This parameter is passed uninitialized. /// true if the specified key has rules. - public bool TryGetValue(Type key, out IList rules) + public bool TryGetValue(Type key, out IList? rules) { return _rulesDictionary.TryGetValue(key, out rules); } diff --git a/src/Microsoft.OpenApi/Writers/OpenApiJsonWriter.cs b/src/Microsoft.OpenApi/Writers/OpenApiJsonWriter.cs index 15b7b07f7..93b4c5e14 100644 --- a/src/Microsoft.OpenApi/Writers/OpenApiJsonWriter.cs +++ b/src/Microsoft.OpenApi/Writers/OpenApiJsonWriter.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System.IO; @@ -34,7 +34,7 @@ public OpenApiJsonWriter(TextWriter textWriter, OpenApiJsonWriterSettings settin /// The text writer. /// Settings for controlling how the OpenAPI document will be written out. /// Setting for allowing the JSON emitted to be in terse format. - public OpenApiJsonWriter(TextWriter textWriter, OpenApiWriterSettings settings, bool terseOutput = false) : base(textWriter, settings) + public OpenApiJsonWriter(TextWriter textWriter, OpenApiWriterSettings? settings, bool terseOutput = false) : base(textWriter, settings) { _produceTerseOutput = terseOutput; } @@ -59,7 +59,7 @@ public override void WriteStartObject() var currentScope = StartScope(ScopeType.Object); - if (previousScope is {Type: ScopeType.Array}) + if (previousScope is { Type: ScopeType.Array }) { currentScope.IsInArray = true; @@ -110,7 +110,7 @@ public override void WriteStartArray() var currentScope = StartScope(ScopeType.Array); - if (previousScope is {Type: ScopeType.Array}) + if (previousScope is { Type: ScopeType.Array }) { currentScope.IsInArray = true; @@ -158,14 +158,14 @@ public override void WritePropertyName(string name) VerifyCanWritePropertyName(name); var currentScope = CurrentScope(); - if (currentScope.ObjectCount != 0) + if (currentScope?.ObjectCount != 0) { Writer.Write(WriterConstants.ObjectMemberSeparator); } WriteLine(); - currentScope.ObjectCount++; + currentScope!.ObjectCount++; WriteIndentation(); diff --git a/src/Microsoft.OpenApi/Writers/OpenApiWriterAnyExtensions.cs b/src/Microsoft.OpenApi/Writers/OpenApiWriterAnyExtensions.cs index f7559f0f7..eee8068a9 100644 --- a/src/Microsoft.OpenApi/Writers/OpenApiWriterAnyExtensions.cs +++ b/src/Microsoft.OpenApi/Writers/OpenApiWriterAnyExtensions.cs @@ -22,7 +22,7 @@ public static class OpenApiWriterAnyExtensions /// The Open API writer. /// The specification extensions. /// Version of the OpenAPI specification that that will be output. - public static void WriteExtensions(this IOpenApiWriter writer, IDictionary extensions, OpenApiSpecVersion specVersion) + public static void WriteExtensions(this IOpenApiWriter writer, IDictionary? extensions, OpenApiSpecVersion specVersion) { Utils.CheckArgumentNull(writer); @@ -49,7 +49,7 @@ public static void WriteExtensions(this IOpenApiWriter writer, IDictionary /// The Open API writer. /// The JsonNode value - public static void WriteAny(this IOpenApiWriter writer, JsonNode node) + public static void WriteAny(this IOpenApiWriter writer, JsonNode? node) { Utils.CheckArgumentNull(writer); @@ -84,34 +84,37 @@ public static void WriteAny(this IOpenApiWriter writer, JsonNode node) } } - private static void WriteArray(this IOpenApiWriter writer, JsonArray array) + private static void WriteArray(this IOpenApiWriter writer, JsonArray? array) { writer.WriteStartArray(); - - foreach (var item in array) + if (array is not null) { - writer.WriteAny(item); - } + foreach (var item in array) + { + writer.WriteAny(item); + } + } writer.WriteEndArray(); } - private static void WriteObject(this IOpenApiWriter writer, JsonObject entity) + private static void WriteObject(this IOpenApiWriter writer, JsonObject? entity) { writer.WriteStartObject(); - - foreach (var item in entity) + if (entity is not null) { - writer.WritePropertyName(item.Key); - writer.WriteAny(item.Value); + foreach (var item in entity) + { + writer.WritePropertyName(item.Key); + writer.WriteAny(item.Value); + } } - writer.WriteEndObject(); } private static void WritePrimitive(this IOpenApiWriter writer, JsonValue jsonValue) { - if (jsonValue.TryGetValue(out string stringValue)) + if (jsonValue.TryGetValue(out string? stringValue)) writer.WriteValue(stringValue); else if (jsonValue.TryGetValue(out DateTime dateTimeValue)) writer.WriteValue(dateTimeValue.ToString("o", CultureInfo.InvariantCulture)); // ISO 8601 format diff --git a/src/Microsoft.OpenApi/Writers/OpenApiWriterBase.cs b/src/Microsoft.OpenApi/Writers/OpenApiWriterBase.cs index aa515af7e..0f212477a 100644 --- a/src/Microsoft.OpenApi/Writers/OpenApiWriterBase.cs +++ b/src/Microsoft.OpenApi/Writers/OpenApiWriterBase.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.Globalization; using System.IO; +using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.OpenApi.Exceptions; @@ -52,7 +53,7 @@ protected OpenApiWriterBase(TextWriter textWriter) : this(textWriter, null) /// /// /// - protected OpenApiWriterBase(TextWriter textWriter, OpenApiWriterSettings settings) + protected OpenApiWriterBase(TextWriter textWriter, OpenApiWriterSettings? settings) { Writer = textWriter; Writer.NewLine = "\n"; @@ -229,7 +230,7 @@ public virtual void WriteEnumerable(IEnumerable collection) /// Write object value. /// /// The object value. - public virtual void WriteValue(object value) + public virtual void WriteValue(object? value) { if (value == null) { @@ -332,7 +333,7 @@ public virtual void WriteIndentation() /// Get current scope. /// /// - protected Scope CurrentScope() + protected Scope? CurrentScope() { return Scopes.Count == 0 ? null : Scopes.Peek(); } @@ -437,7 +438,7 @@ protected void VerifyCanWritePropertyName(string name) } /// - public void WriteV2Examples(IOpenApiWriter writer, OpenApiExample example, OpenApiSpecVersion version) + public static void WriteV2Examples(IOpenApiWriter writer, OpenApiExample example, OpenApiSpecVersion version) { writer.WriteStartObject(); diff --git a/src/Microsoft.OpenApi/Writers/OpenApiWriterExtensions.cs b/src/Microsoft.OpenApi/Writers/OpenApiWriterExtensions.cs index 0e0256f79..ad84d5537 100644 --- a/src/Microsoft.OpenApi/Writers/OpenApiWriterExtensions.cs +++ b/src/Microsoft.OpenApi/Writers/OpenApiWriterExtensions.cs @@ -21,7 +21,7 @@ public static class OpenApiWriterExtensions /// The writer. /// The property name. /// The property value. - public static void WriteProperty(this IOpenApiWriter writer, string name, string value) + public static void WriteProperty(this IOpenApiWriter writer, string name, string? value) { if (value == null) { @@ -39,7 +39,7 @@ public static void WriteProperty(this IOpenApiWriter writer, string name, string /// The writer. /// The property name. /// The property value. - public static void WriteRequiredProperty(this IOpenApiWriter writer, string name, string value) + public static void WriteRequiredProperty(this IOpenApiWriter writer, string name, string? value) { Utils.CheckArgumentNullOrEmpty(name); writer.WritePropertyName(name); @@ -191,8 +191,8 @@ public static void WriteRequiredObject( public static void WriteOptionalCollection( this IOpenApiWriter writer, string name, - IEnumerable elements, - Action action) + IEnumerable? elements, + Action action) { if (elements != null && elements.Any()) { @@ -211,7 +211,7 @@ public static void WriteOptionalCollection( public static void WriteOptionalCollection( this IOpenApiWriter writer, string name, - IEnumerable elements, + IEnumerable? elements, Action action) { if (elements != null && elements.Any()) @@ -248,7 +248,7 @@ public static void WriteRequiredCollection( public static void WriteRequiredMap( this IOpenApiWriter writer, string name, - IDictionary elements, + IDictionary? elements, Action action) { writer.WriteMapInternal(name, elements, action); @@ -264,7 +264,7 @@ public static void WriteRequiredMap( public static void WriteOptionalMap( this IOpenApiWriter writer, string name, - IDictionary elements, + IDictionary? elements, Action action) { if (elements != null && elements.Any()) @@ -283,7 +283,7 @@ public static void WriteOptionalMap( public static void WriteOptionalMap( this IOpenApiWriter writer, string name, - IDictionary elements, + IDictionary? elements, Action action) { if (elements != null && elements.Any()) @@ -302,7 +302,7 @@ public static void WriteOptionalMap( public static void WriteOptionalMap( this IOpenApiWriter writer, string name, - IDictionary elements, + IDictionary? elements, Action action) { if (elements != null && elements.Any()) @@ -321,7 +321,7 @@ public static void WriteOptionalMap( public static void WriteOptionalMap( this IOpenApiWriter writer, string name, - IDictionary> elements, + IDictionary>? elements, Action> action) { if (elements != null && elements.Any()) @@ -341,7 +341,7 @@ public static void WriteOptionalMap( public static void WriteOptionalMap( this IOpenApiWriter writer, string name, - IDictionary elements, + IDictionary? elements, Action action) where T : IOpenApiElement { @@ -362,7 +362,7 @@ public static void WriteOptionalMap( public static void WriteOptionalMap( this IOpenApiWriter writer, string name, - IDictionary elements, + IDictionary? elements, Action action) where T : IOpenApiElement { @@ -383,7 +383,7 @@ public static void WriteOptionalMap( public static void WriteRequiredMap( this IOpenApiWriter writer, string name, - IDictionary elements, + IDictionary? elements, Action action) where T : IOpenApiElement { @@ -421,7 +421,7 @@ private static void WriteCollectionInternal( private static void WriteMapInternal( this IOpenApiWriter writer, string name, - IDictionary elements, + IDictionary? elements, Action action) { WriteMapInternal(writer, name, elements, (w, _, s) => action(w, s)); @@ -430,7 +430,7 @@ private static void WriteMapInternal( private static void WriteMapInternal( this IOpenApiWriter writer, string name, - IDictionary elements, + IDictionary? elements, Action action) { Utils.CheckArgumentNull(action); diff --git a/src/Microsoft.OpenApi/Writers/OpenApiYamlWriter.cs b/src/Microsoft.OpenApi/Writers/OpenApiYamlWriter.cs index aaa160548..49e8f0cb4 100644 --- a/src/Microsoft.OpenApi/Writers/OpenApiYamlWriter.cs +++ b/src/Microsoft.OpenApi/Writers/OpenApiYamlWriter.cs @@ -24,7 +24,7 @@ public OpenApiYamlWriter(TextWriter textWriter) : this(textWriter, null) /// /// The text writer. /// - public OpenApiYamlWriter(TextWriter textWriter, OpenApiWriterSettings settings) : base(textWriter, settings) + public OpenApiYamlWriter(TextWriter textWriter, OpenApiWriterSettings? settings) : base(textWriter, settings) { } @@ -49,7 +49,7 @@ public override void WriteStartObject() var currentScope = StartScope(ScopeType.Object); - if (previousScope is {Type: ScopeType.Array}) + if (previousScope is { Type: ScopeType.Array }) { currentScope.IsInArray = true; @@ -77,7 +77,7 @@ public override void WriteEndObject() if (previousScope.ObjectCount == 0) { // If we are in an object, write a white space preceding the braces. - if (currentScope is {Type: ScopeType.Object}) + if (currentScope is { Type: ScopeType.Object }) { Writer.Write(" "); } @@ -95,7 +95,7 @@ public override void WriteStartArray() var currentScope = StartScope(ScopeType.Array); - if (previousScope is {Type: ScopeType.Array}) + if (previousScope is { Type: ScopeType.Array }) { currentScope.IsInArray = true; @@ -123,7 +123,7 @@ public override void WriteEndArray() if (previousScope.ObjectCount == 0) { // If we are in an object, write a white space preceding the braces. - if (currentScope is {Type: ScopeType.Object}) + if (currentScope is { Type: ScopeType.Object }) { Writer.Write(" "); } @@ -142,7 +142,7 @@ public override void WritePropertyName(string name) var currentScope = CurrentScope(); // If this is NOT the first property in the object, always start a new line and add indentation. - if (currentScope.ObjectCount != 0) + if (currentScope?.ObjectCount != 0) { Writer.WriteLine(); WriteIndentation(); @@ -161,7 +161,7 @@ public override void WritePropertyName(string name) Writer.Write(name); Writer.Write(":"); - currentScope.ObjectCount++; + currentScope!.ObjectCount++; } /// @@ -170,7 +170,7 @@ public override void WritePropertyName(string name) /// The string value. public override void WriteValue(string value) { - if (!UseLiteralStyle || value.IndexOfAny(new[] { '\n', '\r' }) == -1) + if (!UseLiteralStyle || value?.IndexOfAny(new[] { '\n', '\r' }) == -1) { WriteValueSeparator(); @@ -190,7 +190,7 @@ public override void WriteValue(string value) WriteChompingIndicator(value); // Write indentation indicator when it starts with spaces - if (value.StartsWith(" ", StringComparison.OrdinalIgnoreCase)) + if (value is not null && value.StartsWith(" ", StringComparison.OrdinalIgnoreCase)) { Writer.Write(IndentationString.Length); } @@ -199,7 +199,7 @@ public override void WriteValue(string value) IncreaseIndentation(); - using (var reader = new StringReader(value)) + using (var reader = new StringReader(value!)) { var firstLine = true; while (reader.ReadLine() is var line && line != null) @@ -223,10 +223,10 @@ public override void WriteValue(string value) } } - private void WriteChompingIndicator(string value) + private void WriteChompingIndicator(string? value) { var trailingNewlines = 0; - var end = value.Length - 1; + var end = value!.Length - 1; // We only need to know whether there are 0, 1, or more trailing newlines while (end >= 0 && trailingNewlines < 2) { @@ -288,8 +288,9 @@ protected override void WriteValueSeparator() { if (IsArrayScope()) { + var objectCount = CurrentScope()!.ObjectCount; // If array is the outermost scope and this is the first item, there is no need to insert a newline. - if (!IsTopLevelScope() || CurrentScope().ObjectCount != 0) + if (!IsTopLevelScope() || objectCount != 0) { Writer.WriteLine(); } @@ -297,7 +298,7 @@ protected override void WriteValueSeparator() WriteIndentation(); Writer.Write(WriterConstants.PrefixOfArrayItem); - CurrentScope().ObjectCount++; + CurrentScope()!.ObjectCount++; } else { diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Formatters/PowerShellFormatterTests.cs b/test/Microsoft.OpenApi.Hidi.Tests/Formatters/PowerShellFormatterTests.cs index 49b020a10..92cfae013 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Formatters/PowerShellFormatterTests.cs +++ b/test/Microsoft.OpenApi.Hidi.Tests/Formatters/PowerShellFormatterTests.cs @@ -51,7 +51,7 @@ public void FormatOperationIdsInOpenAPIDocument(string operationId, string expec walker.Walk(openApiDocument); // Assert - Assert.Equal(expectedOperationId, openApiDocument.Paths[path].Operations[operationType].OperationId); + Assert.Equal(expectedOperationId, openApiDocument.Paths[path].Operations?[operationType].OperationId); } [Fact] @@ -68,20 +68,20 @@ public void RemoveAnyOfAndOneOfFromSchema() Assert.NotNull(openApiDocument.Components); Assert.NotNull(openApiDocument.Components.Schemas); var testSchema = openApiDocument.Components.Schemas["TestSchema"]; - var averageAudioDegradationProperty = testSchema.Properties["averageAudioDegradation"]; - var defaultPriceProperty = testSchema.Properties["defaultPrice"]; + var averageAudioDegradationProperty = testSchema.Properties?["averageAudioDegradation"]; + var defaultPriceProperty = testSchema.Properties?["defaultPrice"]; // Assert Assert.NotNull(openApiDocument.Components); Assert.NotNull(openApiDocument.Components.Schemas); Assert.NotNull(testSchema); - Assert.Null(averageAudioDegradationProperty.AnyOf); - Assert.Equal(JsonSchemaType.Number | JsonSchemaType.Null, averageAudioDegradationProperty.Type); - Assert.Equal("float", averageAudioDegradationProperty.Format); - Assert.Equal(JsonSchemaType.Null, averageAudioDegradationProperty.Type & JsonSchemaType.Null); - Assert.Null(defaultPriceProperty.OneOf); - Assert.Equal(JsonSchemaType.Number, defaultPriceProperty.Type); - Assert.Equal("double", defaultPriceProperty.Format); + Assert.Null(averageAudioDegradationProperty?.AnyOf); + Assert.Equal(JsonSchemaType.Number | JsonSchemaType.Null, averageAudioDegradationProperty?.Type); + Assert.Equal("float", averageAudioDegradationProperty?.Format); + Assert.Equal(JsonSchemaType.Null, averageAudioDegradationProperty?.Type & JsonSchemaType.Null); + Assert.Null(defaultPriceProperty?.OneOf); + Assert.Equal(JsonSchemaType.Number, defaultPriceProperty?.Type); + Assert.Equal("double", defaultPriceProperty?.Format); Assert.NotNull(testSchema.AdditionalProperties); } @@ -96,7 +96,7 @@ public void ResolveFunctionParameters() var walker = new OpenApiWalker(powerShellFormatter); walker.Walk(openApiDocument); - var idsParameter = openApiDocument.Paths["/foo"].Operations[HttpMethod.Get].Parameters?.Where(static p => p.Name == "ids").FirstOrDefault(); + var idsParameter = openApiDocument.Paths["/foo"].Operations?[HttpMethod.Get].Parameters?.Where(static p => p.Name == "ids").FirstOrDefault(); // Assert Assert.Null(idsParameter?.Content); diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs index 57d2d5098..7702c56c1 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs +++ b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs @@ -104,9 +104,9 @@ public void TestPredicateFiltersUsingRelativeRequestUrls() var predicate = OpenApiFilterService.CreatePredicate(requestUrls: requestUrls, source: openApiDocument); // Then - Assert.True(predicate("/foo", HttpMethod.Get, null)); - Assert.True(predicate("/foo", HttpMethod.Post, null)); - Assert.False(predicate("/foo", HttpMethod.Patch, null)); + Assert.True(predicate("/foo", HttpMethod.Get, null!)); + Assert.True(predicate("/foo", HttpMethod.Post, null!)); + Assert.False(predicate("/foo", HttpMethod.Patch, null!)); } [Fact] @@ -157,7 +157,7 @@ public void CreateFilteredDocumentUsingPredicateFromRequestUrl() // Assert that there's only 1 parameter in the subset document Assert.NotNull(subsetDoc); Assert.NotEmpty(subsetDoc.Paths); - Assert.Single(subsetDoc.Paths.First().Value.Parameters); + Assert.Single(subsetDoc.Paths.First().Value.Parameters!); } [Fact] @@ -239,52 +239,55 @@ public async Task CopiesOverAllReferencedComponentsToTheSubsetDocumentCorrectly( var settings = new OpenApiReaderSettings(); settings.AddYamlReader(); var doc = (await OpenApiDocument.LoadAsync(stream, "yaml", settings)).Document; - + // validated the tags are read as references - var openApiOperationTags = doc.Paths["/items"].Operations[HttpMethod.Get].Tags?.ToArray(); + var openApiOperationTags = doc?.Paths["/items"].Operations?[HttpMethod.Get].Tags?.ToArray(); Assert.NotNull(openApiOperationTags); Assert.Single(openApiOperationTags); Assert.True(openApiOperationTags[0].UnresolvedReference); - - var predicate = OpenApiFilterService.CreatePredicate(operationIds: operationIds); - var subsetOpenApiDocument = OpenApiFilterService.CreateFilteredDocument(doc, predicate); - - var response = subsetOpenApiDocument.Paths["/items"].Operations[HttpMethod.Get]?.Responses?["200"]; - var responseHeader = response?.Headers["x-custom-header"]; - var mediaTypeExample = response?.Content["application/json"]?.Examples?.First().Value; - var targetHeaders = subsetOpenApiDocument.Components?.Headers; - var targetExamples = subsetOpenApiDocument.Components?.Examples; - // Assert - Assert.Same(doc.Servers, subsetOpenApiDocument.Servers); - var headerReference = Assert.IsType(responseHeader); - Assert.False(headerReference.UnresolvedReference); - var exampleReference = Assert.IsType(mediaTypeExample); - Assert.False(exampleReference?.UnresolvedReference); - Assert.NotNull(targetHeaders); - Assert.Single(targetHeaders); - Assert.NotNull(targetExamples); - Assert.Single(targetExamples); - // validated the tags of the trimmed document are read as references - var trimmedOpenApiOperationTags = subsetOpenApiDocument.Paths["/items"].Operations[HttpMethod.Get].Tags?.ToArray(); - Assert.NotNull(trimmedOpenApiOperationTags); - Assert.Single(trimmedOpenApiOperationTags); - Assert.True(trimmedOpenApiOperationTags[0].UnresolvedReference); - - // Finally try to write the trimmed document as v3 document - var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputStringWriter) + var predicate = OpenApiFilterService.CreatePredicate(operationIds: operationIds); + if (doc is not null) { - Settings = new OpenApiWriterSettings() + var subsetOpenApiDocument = OpenApiFilterService.CreateFilteredDocument(doc, predicate); + + var response = subsetOpenApiDocument.Paths?["/items"].Operations?[HttpMethod.Get]?.Responses?["200"]; + var responseHeader = response?.Headers?["x-custom-header"]; + var mediaTypeExample = response?.Content?["application/json"]?.Examples?.First().Value; + var targetHeaders = subsetOpenApiDocument.Components?.Headers; + var targetExamples = subsetOpenApiDocument.Components?.Examples; + + // Assert + Assert.Same(doc.Servers, subsetOpenApiDocument.Servers); + var headerReference = Assert.IsType(responseHeader); + Assert.False(headerReference.UnresolvedReference); + var exampleReference = Assert.IsType(mediaTypeExample); + Assert.False(exampleReference?.UnresolvedReference); + Assert.NotNull(targetHeaders); + Assert.Single(targetHeaders); + Assert.NotNull(targetExamples); + Assert.Single(targetExamples); + // validated the tags of the trimmed document are read as references + var trimmedOpenApiOperationTags = subsetOpenApiDocument.Paths?["/items"].Operations?[HttpMethod.Get].Tags?.ToArray(); + Assert.NotNull(trimmedOpenApiOperationTags); + Assert.Single(trimmedOpenApiOperationTags); + Assert.True(trimmedOpenApiOperationTags[0].UnresolvedReference); + + // Finally try to write the trimmed document as v3 document + var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); + var writer = new OpenApiJsonWriter(outputStringWriter) { - InlineExternalReferences = true, - InlineLocalReferences = true - } - }; - subsetOpenApiDocument.SerializeAsV3(writer); - await writer.FlushAsync(); - var result = outputStringWriter.ToString(); - Assert.NotEmpty(result); + Settings = new OpenApiWriterSettings() + { + InlineExternalReferences = true, + InlineLocalReferences = true + } + }; + subsetOpenApiDocument.SerializeAsV3(writer); + await writer.FlushAsync(); + var result = outputStringWriter.ToString(); + Assert.NotEmpty(result); + } } [Theory] @@ -299,8 +302,8 @@ public void ReturnsPathParametersOnSlicingBasedOnOperationIdsOrTags(string? oper // Assert foreach (var pathItem in subsetOpenApiDocument.Paths) { - Assert.True(pathItem.Value.Parameters.Any()); - Assert.Single(pathItem.Value.Parameters); + Assert.True(pathItem.Value.Parameters!.Any()); + Assert.Single(pathItem.Value.Parameters!); } } } diff --git a/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/OpenApiDocumentMock.cs b/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/OpenApiDocumentMock.cs index 0cc1bc2fb..71768bfbe 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/OpenApiDocumentMock.cs +++ b/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/OpenApiDocumentMock.cs @@ -678,23 +678,23 @@ public static OpenApiDocument CreateOpenApiDocument() } } }; - document.Paths[getTeamsActivityByPeriodPath].Operations[HttpMethod.Get].Tags = new HashSet {new OpenApiTagReference("reports.Functions", document)}; - document.Paths[getTeamsActivityByDatePath].Operations[HttpMethod.Get].Tags = new HashSet {new OpenApiTagReference("reports.Functions", document)}; - document.Paths[usersPath].Operations[HttpMethod.Get].Tags = new HashSet {new OpenApiTagReference("users.user", document)}; - document.Paths[usersByIdPath].Operations[HttpMethod.Get].Tags = new HashSet {new OpenApiTagReference("users.user", document)}; - document.Paths[usersByIdPath].Operations[HttpMethod.Patch].Tags = new HashSet {new OpenApiTagReference("users.user", document)}; - document.Paths[messagesByIdPath].Operations[HttpMethod.Get].Tags = new HashSet {new OpenApiTagReference("users.message", document)}; - document.Paths[administrativeUnitRestorePath].Operations[HttpMethod.Post].Tags = new HashSet {new OpenApiTagReference("administrativeUnits.Actions", document)}; - document.Paths[logoPath].Operations[HttpMethod.Put].Tags = new HashSet {new OpenApiTagReference("applications.application", document)}; - document.Paths[securityProfilesPath].Operations[HttpMethod.Get].Tags = new HashSet {new OpenApiTagReference("security.hostSecurityProfile", document)}; - document.Paths[communicationsCallsKeepAlivePath].Operations[HttpMethod.Post].Tags = new HashSet {new OpenApiTagReference("communications.Actions", document)}; - document.Paths[eventsDeltaPath].Operations[HttpMethod.Get].Tags = new HashSet {new OpenApiTagReference("groups.Functions", document)}; - document.Paths[refPath].Operations[HttpMethod.Get].Tags = new HashSet {new OpenApiTagReference("applications.directoryObject", document)}; - ((OpenApiSchema)document.Paths[usersPath].Operations[HttpMethod.Get].Responses!["200"].Content[applicationJsonMediaType].Schema!.Properties["value"]).Items = new OpenApiSchemaReference("microsoft.graph.user", document); - document.Paths[usersByIdPath].Operations[HttpMethod.Get].Responses!["200"].Content[applicationJsonMediaType].Schema = new OpenApiSchemaReference("microsoft.graph.user", document); - document.Paths[messagesByIdPath].Operations[HttpMethod.Get].Responses!["200"].Content[applicationJsonMediaType].Schema = new OpenApiSchemaReference("microsoft.graph.message", document); - ((OpenApiSchema)document.Paths[securityProfilesPath].Operations[HttpMethod.Get].Responses!["200"].Content[applicationJsonMediaType].Schema!.Properties["value"]).Items = new OpenApiSchemaReference("microsoft.graph.networkInterface", document); - ((OpenApiSchema)document.Paths[eventsDeltaPath].Operations[HttpMethod.Get].Responses!["200"].Content[applicationJsonMediaType].Schema!.Properties["value"]).Items = new OpenApiSchemaReference("microsoft.graph.event", document); + document.Paths[getTeamsActivityByPeriodPath].Operations![HttpMethod.Get].Tags = new HashSet {new OpenApiTagReference("reports.Functions", document)}; + document.Paths[getTeamsActivityByDatePath].Operations![HttpMethod.Get].Tags = new HashSet {new OpenApiTagReference("reports.Functions", document)}; + document.Paths[usersPath].Operations![HttpMethod.Get].Tags = new HashSet {new OpenApiTagReference("users.user", document)}; + document.Paths[usersByIdPath].Operations![HttpMethod.Get].Tags = new HashSet {new OpenApiTagReference("users.user", document)}; + document.Paths[usersByIdPath].Operations![HttpMethod.Patch].Tags = new HashSet {new OpenApiTagReference("users.user", document)}; + document.Paths[messagesByIdPath].Operations![HttpMethod.Get].Tags = new HashSet {new OpenApiTagReference("users.message", document)}; + document.Paths[administrativeUnitRestorePath].Operations![HttpMethod.Post].Tags = new HashSet {new OpenApiTagReference("administrativeUnits.Actions", document)}; + document.Paths[logoPath].Operations![HttpMethod.Put].Tags = new HashSet {new OpenApiTagReference("applications.application", document)}; + document.Paths[securityProfilesPath].Operations![HttpMethod.Get].Tags = new HashSet {new OpenApiTagReference("security.hostSecurityProfile", document)}; + document.Paths[communicationsCallsKeepAlivePath].Operations![HttpMethod.Post].Tags = new HashSet {new OpenApiTagReference("communications.Actions", document)}; + document.Paths[eventsDeltaPath].Operations![HttpMethod.Get].Tags = new HashSet {new OpenApiTagReference("groups.Functions", document)}; + document.Paths[refPath].Operations![HttpMethod.Get].Tags = new HashSet {new OpenApiTagReference("applications.directoryObject", document)}; + ((OpenApiSchema)document.Paths[usersPath].Operations![HttpMethod.Get].Responses!["200"].Content![applicationJsonMediaType].Schema!.Properties!["value"]).Items = new OpenApiSchemaReference("microsoft.graph.user", document); + document.Paths[usersByIdPath].Operations![HttpMethod.Get].Responses!["200"].Content![applicationJsonMediaType].Schema = new OpenApiSchemaReference("microsoft.graph.user", document); + document.Paths[messagesByIdPath].Operations![HttpMethod.Get].Responses!["200"].Content![applicationJsonMediaType].Schema = new OpenApiSchemaReference("microsoft.graph.message", document); + ((OpenApiSchema)document.Paths[securityProfilesPath].Operations![HttpMethod.Get].Responses!["200"].Content![applicationJsonMediaType].Schema!.Properties!["value"]).Items = new OpenApiSchemaReference("microsoft.graph.networkInterface", document); + ((OpenApiSchema)document.Paths[eventsDeltaPath].Operations![HttpMethod.Get].Responses!["200"].Content![applicationJsonMediaType].Schema!.Properties!["value"]).Items = new OpenApiSchemaReference("microsoft.graph.event", document); return document; } } diff --git a/test/Microsoft.OpenApi.Readers.Tests/ParseNodeTests.cs b/test/Microsoft.OpenApi.Readers.Tests/ParseNodeTests.cs index 8dfb20322..082c5e5df 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/ParseNodeTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/ParseNodeTests.cs @@ -28,7 +28,7 @@ public void BrokenSimpleList() var result = OpenApiDocument.Parse(input, "yaml", SettingsFixture.ReaderSettings); Assert.Equivalent(new List() { - new OpenApiError(new OpenApiReaderException("Expected a value.")) + new OpenApiError(new OpenApiReaderException("Expected a value while parsing at #/schemes.")) }, result.Diagnostic.Errors); } diff --git a/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/ConvertToOpenApiReferenceV2Tests.cs b/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/ConvertToOpenApiReferenceV2Tests.cs deleted file mode 100644 index 59c8a81f8..000000000 --- a/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/ConvertToOpenApiReferenceV2Tests.cs +++ /dev/null @@ -1,128 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. - -using Microsoft.OpenApi.Models; -using Microsoft.OpenApi.Reader; -using Microsoft.OpenApi.Reader.V2; -using Xunit; - -namespace Microsoft.OpenApi.Readers.Tests -{ - public class ConvertToOpenApiReferenceV2Tests - { - public OpenApiDiagnostic Diagnostic { get; } - - public ConvertToOpenApiReferenceV2Tests() - { - Diagnostic = new(); - } - - [Fact] - public void ParseExternalReferenceToV2OpenApi() - { - // Arrange - var versionService = new OpenApiV2VersionService(Diagnostic); - var externalResource = "externalSchema.json"; - var id = "mySchema"; - var input = $"{externalResource}#/definitions/{id}"; - - // Act - var reference = versionService.ConvertToOpenApiReference(input, null); - - // Assert - Assert.Equal(externalResource, reference.ExternalResource); - Assert.NotNull(reference.Type); - Assert.Equal(id, reference.Id); - } - - [Fact] - public void ParseExternalReference() - { - // Arrange - var versionService = new OpenApiV2VersionService(Diagnostic); - var externalResource = "externalSchema.json"; - var id = "/externalPathSegment1/externalPathSegment2/externalPathSegment3"; - var input = $"{externalResource}#{id}"; - - // Act - var reference = versionService.ConvertToOpenApiReference(input, null); - - // Assert - Assert.Equal(externalResource, reference.ExternalResource); - Assert.Null(reference.Type); - Assert.Equal(id, reference.Id); - } - - [Fact] - public void ParseLocalParameterReference() - { - // Arrange - var versionService = new OpenApiV2VersionService(Diagnostic); - var referenceType = ReferenceType.Parameter; - var id = "parameterId"; - var input = $"#/parameters/{id}"; - - // Act - var reference = versionService.ConvertToOpenApiReference(input, referenceType); - - // Assert - Assert.Equal(referenceType, reference.Type); - Assert.Null(reference.ExternalResource); - Assert.Equal(id, reference.Id); - } - - [Fact] - public void ParseLocalSchemaReference() - { - // Arrange - var versionService = new OpenApiV2VersionService(Diagnostic); - var referenceType = ReferenceType.Schema; - var id = "parameterId"; - var input = $"#/definitions/{id}"; - - // Act - var reference = versionService.ConvertToOpenApiReference(input, referenceType); - - // Assert - Assert.Equal(referenceType, reference.Type); - Assert.Null(reference.ExternalResource); - Assert.Equal(id, reference.Id); - } - - [Fact] - public void ParseTagReference() - { - // Arrange - var versionService = new OpenApiV2VersionService(Diagnostic); - var referenceType = ReferenceType.Tag; - var id = "tagId"; - var input = $"{id}"; - - // Act - var reference = versionService.ConvertToOpenApiReference(input, referenceType); - - // Assert - Assert.Equal(referenceType, reference.Type); - Assert.Null(reference.ExternalResource); - Assert.Equal(id, reference.Id); - } - - [Fact] - public void ParseSecuritySchemeReference() - { - // Arrange - var versionService = new OpenApiV2VersionService(Diagnostic); - var referenceType = ReferenceType.SecurityScheme; - var id = "securitySchemeId"; - var input = $"{id}"; - - // Act - var reference = versionService.ConvertToOpenApiReference(input, referenceType); - - // Assert - Assert.Equal(referenceType, reference.Type); - Assert.Null(reference.ExternalResource); - Assert.Equal(id, reference.Id); - } - } -} diff --git a/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/ConvertToOpenApiReferenceV3Tests.cs b/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/ConvertToOpenApiReferenceV3Tests.cs deleted file mode 100644 index 0104f5208..000000000 --- a/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/ConvertToOpenApiReferenceV3Tests.cs +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. - -using Microsoft.OpenApi.Models; -using Microsoft.OpenApi.Reader; -using Microsoft.OpenApi.Reader.V3; -using Xunit; - -namespace Microsoft.OpenApi.Readers.Tests -{ - public class ConvertToOpenApiReferenceV3Tests - { - public OpenApiDiagnostic Diagnostic { get; } - - public ConvertToOpenApiReferenceV3Tests() - { - Diagnostic = new(); - } - - [Fact] - public void ParseExternalReference() - { - // Arrange - var versionService = new OpenApiV3VersionService(Diagnostic); - var externalResource = "externalSchema.json"; - var id = "/externalPathSegment1/externalPathSegment2/externalPathSegment3"; - var input = $"{externalResource}#{id}"; - - // Act - var reference = versionService.ConvertToOpenApiReference(input, null); - - // Assert - Assert.Null(reference.Type); - Assert.Equal(externalResource, reference.ExternalResource); - Assert.Equal(id, reference.Id); - } - - [Fact] - public void ParseLocalParameterReference() - { - // Arrange - var versionService = new OpenApiV3VersionService(Diagnostic); - var referenceType = ReferenceType.Parameter; - var id = "parameterId"; - var input = $"#/components/parameters/{id}"; - - // Act - var reference = versionService.ConvertToOpenApiReference(input, referenceType); - - // Assert - Assert.Equal(referenceType, reference.Type); - Assert.Null(reference.ExternalResource); - Assert.Equal(id, reference.Id); - } - - [Fact] - public void ParseLocalSchemaReference() - { - // Arrange - var versionService = new OpenApiV3VersionService(Diagnostic); - var referenceType = ReferenceType.Schema; - var id = "schemaId"; - var input = $"#/components/schemas/{id}"; - - // Act - var reference = versionService.ConvertToOpenApiReference(input, referenceType); - - // Assert - Assert.Equal(referenceType, reference.Type); - Assert.Null(reference.ExternalResource); - Assert.Equal(id, reference.Id); - } - - [Fact] - public void ParseTagReference() - { - // Arrange - var versionService = new OpenApiV3VersionService(Diagnostic); - var referenceType = ReferenceType.Tag; - var id = "tagId"; - var input = $"{id}"; - - // Act - var reference = versionService.ConvertToOpenApiReference(input, referenceType); - - // Assert - Assert.Equal(referenceType, reference.Type); - Assert.Null(reference.ExternalResource); - Assert.Equal(id, reference.Id); - } - - [Fact] - public void ParseSecuritySchemeReference() - { - // Arrange - var versionService = new OpenApiV3VersionService(Diagnostic); - var referenceType = ReferenceType.SecurityScheme; - var id = "securitySchemeId"; - var input = $"{id}"; - - // Act - var reference = versionService.ConvertToOpenApiReference(input, referenceType); - - // Assert - Assert.Equal(referenceType, reference.Type); - Assert.Null(reference.ExternalResource); - Assert.Equal(id, reference.Id); - } - - [Fact] - public void ParseLocalFileReference() - { - // Arrange - var versionService = new OpenApiV3VersionService(Diagnostic); - var referenceType = ReferenceType.Schema; - var input = $"../schemas/collection.json"; - - // Act - var reference = versionService.ConvertToOpenApiReference(input, referenceType); - - // Assert - Assert.Equal(referenceType, reference.Type); - Assert.Equal(input, reference.ExternalResource); - } - - [Fact] - public void ParseExternalPathReference() - { - // Arrange - var versionService = new OpenApiV3VersionService(Diagnostic); - var externalResource = "externalSchema.json"; - var referenceJsonEscaped = "/paths/~1applications~1{AppUUID}~1services~1{ServiceName}"; - var input = $"{externalResource}#{referenceJsonEscaped}"; - var id = "/applications/{AppUUID}/services/{ServiceName}"; - - // Act - var reference = versionService.ConvertToOpenApiReference(input, null); - - // Assert - Assert.Null(reference.Type); - Assert.Equal(externalResource, reference.ExternalResource); - Assert.Equal(id, reference.Id); - } - } -} diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiReferenceTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiReferenceTests.cs index b75cb89e4..85686fcfa 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiReferenceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiReferenceTests.cs @@ -38,14 +38,14 @@ public void SettingInternalReferenceForComponentsStyleReferenceShouldSucceed( } [Theory] - [InlineData("Pet.json", "Pet.json", null, null)] - [InlineData("Pet.yaml", "Pet.yaml", null, null)] - [InlineData("abc", "abc", null, null)] + [InlineData("Pet.json", "Pet.json", null, ReferenceType.Schema)] + [InlineData("Pet.yaml", "Pet.yaml", null, ReferenceType.Schema)] + [InlineData("abc", "abc", null, ReferenceType.Schema)] [InlineData("Pet.json#/components/schemas/Pet", "Pet.json", "Pet", ReferenceType.Schema)] [InlineData("Pet.yaml#/components/schemas/Pet", "Pet.yaml", "Pet", ReferenceType.Schema)] [InlineData("abc#/components/schemas/Pet", "abc", "Pet", ReferenceType.Schema)] [InlineData("abc#/components/schemas/HttpsValidationProblem", "abc", "HttpsValidationProblem", ReferenceType.Schema)] - public void SettingExternalReferenceV3ShouldSucceed(string expected, string externalResource, string id, ReferenceType? type) + public void SettingExternalReferenceV3ShouldSucceed(string expected, string externalResource, string id, ReferenceType type) { // Arrange & Act var reference = new OpenApiReference @@ -63,13 +63,13 @@ public void SettingExternalReferenceV3ShouldSucceed(string expected, string exte } [Theory] - [InlineData("Pet.json", "Pet.json", null, null)] - [InlineData("Pet.yaml", "Pet.yaml", null, null)] - [InlineData("abc", "abc", null, null)] + [InlineData("Pet.json", "Pet.json", null, ReferenceType.Schema)] + [InlineData("Pet.yaml", "Pet.yaml", null, ReferenceType.Schema)] + [InlineData("abc", "abc", null, ReferenceType.Schema)] [InlineData("Pet.json#/definitions/Pet", "Pet.json", "Pet", ReferenceType.Schema)] [InlineData("Pet.yaml#/definitions/Pet", "Pet.yaml", "Pet", ReferenceType.Schema)] [InlineData("abc#/definitions/Pet", "abc", "Pet", ReferenceType.Schema)] - public void SettingExternalReferenceV2ShouldSucceed(string expected, string externalResource, string id, ReferenceType? type) + public void SettingExternalReferenceV2ShouldSucceed(string expected, string externalResource, string id, ReferenceType type) { // Arrange & Act var reference = new OpenApiReference diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index 2e672dde0..6685b34d8 100644 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -27,8 +27,8 @@ namespace Microsoft.OpenApi.Exceptions { public OpenApiException() { } public OpenApiException(string message) { } - public OpenApiException(string message, System.Exception innerException) { } - public string Pointer { get; set; } + public OpenApiException(string message, System.Exception? innerException) { } + public string? Pointer { get; set; } } [System.Serializable] public class OpenApiReaderException : Microsoft.OpenApi.Exceptions.OpenApiException @@ -37,7 +37,6 @@ namespace Microsoft.OpenApi.Exceptions public OpenApiReaderException(string message) { } public OpenApiReaderException(string message, Microsoft.OpenApi.Reader.ParsingContext context) { } public OpenApiReaderException(string message, System.Exception innerException) { } - public OpenApiReaderException(string message, System.Text.Json.Nodes.JsonNode node) { } } [System.Serializable] public class OpenApiUnsupportedSpecVersionException : System.Exception @@ -50,7 +49,7 @@ namespace Microsoft.OpenApi.Exceptions { public OpenApiWriterException() { } public OpenApiWriterException(string message) { } - public OpenApiWriterException(string message, System.Exception innerException) { } + public OpenApiWriterException(string message, System.Exception? innerException) { } } } namespace Microsoft.OpenApi.Expressions @@ -60,9 +59,9 @@ namespace Microsoft.OpenApi.Expressions public const string Body = "body"; public const string PointerPrefix = "#"; public BodyExpression() { } - public BodyExpression(Microsoft.OpenApi.JsonPointer pointer) { } + public BodyExpression(Microsoft.OpenApi.JsonPointer? pointer) { } public override string Expression { get; } - public string Fragment { get; } + public string? Fragment { get; } } public class CompositeExpression : Microsoft.OpenApi.Expressions.RuntimeExpression { @@ -75,7 +74,7 @@ namespace Microsoft.OpenApi.Expressions public const string Header = "header."; public HeaderExpression(string token) { } public override string Expression { get; } - public string Token { get; } + public string? Token { get; } } public sealed class MethodExpression : Microsoft.OpenApi.Expressions.RuntimeExpression { @@ -88,14 +87,14 @@ namespace Microsoft.OpenApi.Expressions public const string Path = "path."; public PathExpression(string name) { } public override string Expression { get; } - public string Name { get; } + public string? Name { get; } } public sealed class QueryExpression : Microsoft.OpenApi.Expressions.SourceExpression { public const string Query = "query."; public QueryExpression(string name) { } public override string Expression { get; } - public string Name { get; } + public string? Name { get; } } public sealed class RequestExpression : Microsoft.OpenApi.Expressions.RuntimeExpression { @@ -116,16 +115,16 @@ namespace Microsoft.OpenApi.Expressions public const string Prefix = "$"; protected RuntimeExpression() { } public abstract string Expression { get; } - public bool Equals(Microsoft.OpenApi.Expressions.RuntimeExpression obj) { } - public override bool Equals(object obj) { } + public bool Equals(Microsoft.OpenApi.Expressions.RuntimeExpression? obj) { } + public override bool Equals(object? obj) { } public override int GetHashCode() { } public override string ToString() { } public static Microsoft.OpenApi.Expressions.RuntimeExpression Build(string expression) { } } public abstract class SourceExpression : Microsoft.OpenApi.Expressions.RuntimeExpression { - protected SourceExpression(string value) { } - protected string Value { get; } + protected SourceExpression(string? value) { } + protected string? Value { get; } public new static Microsoft.OpenApi.Expressions.SourceExpression Build(string expression) { } } public sealed class StatusCodeExpression : Microsoft.OpenApi.Expressions.RuntimeExpression @@ -146,7 +145,7 @@ namespace Microsoft.OpenApi.Extensions public static class EnumExtensions { [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2075", Justification="Fields are never trimmed for enum types.")] - public static T GetAttributeOfType(this System.Enum enumValue) + public static T? GetAttributeOfType(this System.Enum enumValue) where T : System.Attribute { } public static string GetDisplayName(this System.Enum enumValue) { } } @@ -179,12 +178,12 @@ namespace Microsoft.OpenApi.Extensions where T : Microsoft.OpenApi.Interfaces.IOpenApiSerializable { } public static System.Threading.Tasks.Task SerializeAsync(this T element, System.IO.Stream stream, Microsoft.OpenApi.OpenApiSpecVersion specVersion, Microsoft.OpenApi.OpenApiFormat format, System.Threading.CancellationToken cancellationToken = default) where T : Microsoft.OpenApi.Interfaces.IOpenApiSerializable { } - public static System.Threading.Tasks.Task SerializeAsync(this T element, System.IO.Stream stream, Microsoft.OpenApi.OpenApiSpecVersion specVersion, Microsoft.OpenApi.OpenApiFormat format, Microsoft.OpenApi.Writers.OpenApiWriterSettings settings, System.Threading.CancellationToken cancellationToken = default) + public static System.Threading.Tasks.Task SerializeAsync(this T element, System.IO.Stream stream, Microsoft.OpenApi.OpenApiSpecVersion specVersion, Microsoft.OpenApi.OpenApiFormat format, Microsoft.OpenApi.Writers.OpenApiWriterSettings? settings = null, System.Threading.CancellationToken cancellationToken = default) where T : Microsoft.OpenApi.Interfaces.IOpenApiSerializable { } } public static class OpenApiServerExtensions { - public static string ReplaceServerUrlVariables(this Microsoft.OpenApi.Models.OpenApiServer server, System.Collections.Generic.IDictionary values = null) { } + public static string? ReplaceServerUrlVariables(this Microsoft.OpenApi.Models.OpenApiServer server, System.Collections.Generic.IDictionary? values = null) { } } public static class OpenApiTypeMapper { @@ -201,12 +200,12 @@ namespace Microsoft.OpenApi.Interfaces public interface IDiagnostic { } public interface IMetadataContainer { - System.Collections.Generic.IDictionary Metadata { get; set; } + System.Collections.Generic.IDictionary? Metadata { get; set; } } public interface IOpenApiElement { } public interface IOpenApiExtensible : Microsoft.OpenApi.Interfaces.IOpenApiElement { - System.Collections.Generic.IDictionary Extensions { get; set; } + System.Collections.Generic.IDictionary? Extensions { get; set; } } public interface IOpenApiExtension { @@ -214,13 +213,13 @@ namespace Microsoft.OpenApi.Interfaces } public interface IOpenApiReadOnlyExtensible { - System.Collections.Generic.IDictionary Extensions { get; } + System.Collections.Generic.IDictionary? Extensions { get; } } public interface IOpenApiReader { Microsoft.OpenApi.Reader.ReadResult Read(System.IO.MemoryStream input, Microsoft.OpenApi.Reader.OpenApiReaderSettings settings); System.Threading.Tasks.Task ReadAsync(System.IO.Stream input, Microsoft.OpenApi.Reader.OpenApiReaderSettings settings, System.Threading.CancellationToken cancellationToken = default); - T ReadFragment(System.IO.MemoryStream input, Microsoft.OpenApi.OpenApiSpecVersion version, Microsoft.OpenApi.Models.OpenApiDocument openApiDocument, out Microsoft.OpenApi.Reader.OpenApiDiagnostic diagnostic, Microsoft.OpenApi.Reader.OpenApiReaderSettings settings = null) + T? ReadFragment(System.IO.MemoryStream input, Microsoft.OpenApi.OpenApiSpecVersion version, Microsoft.OpenApi.Models.OpenApiDocument openApiDocument, out Microsoft.OpenApi.Reader.OpenApiDiagnostic diagnostic, Microsoft.OpenApi.Reader.OpenApiReaderSettings? settings = null) where T : Microsoft.OpenApi.Interfaces.IOpenApiElement; } public interface IOpenApiReferenceHolder : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiSerializable @@ -256,7 +255,7 @@ namespace Microsoft.OpenApi public class JsonPointer { public JsonPointer(string pointer) { } - public Microsoft.OpenApi.JsonPointer ParentPointer { get; } + public Microsoft.OpenApi.JsonPointer? ParentPointer { get; } public string[] Tokens { get; } public override string ToString() { } } @@ -341,101 +340,101 @@ namespace Microsoft.OpenApi.Models.Interfaces { public interface IOpenApiCallback : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable { - System.Collections.Generic.Dictionary PathItems { get; } + System.Collections.Generic.Dictionary? PathItems { get; } } public interface IOpenApiDescribedElement : Microsoft.OpenApi.Interfaces.IOpenApiElement { - string Description { get; set; } + string? Description { get; set; } } public interface IOpenApiExample : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiSummarizedElement { - string ExternalValue { get; } - System.Text.Json.Nodes.JsonNode Value { get; } + string? ExternalValue { get; } + System.Text.Json.Nodes.JsonNode? Value { get; } } public interface IOpenApiHeader : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement { bool AllowEmptyValue { get; } bool AllowReserved { get; } - System.Collections.Generic.IDictionary Content { get; } + System.Collections.Generic.IDictionary? Content { get; } bool Deprecated { get; } - System.Text.Json.Nodes.JsonNode Example { get; } - System.Collections.Generic.IDictionary Examples { get; } + System.Text.Json.Nodes.JsonNode? Example { get; } + System.Collections.Generic.IDictionary? Examples { get; } bool Explode { get; } bool Required { get; } - Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema Schema { get; } + Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema? Schema { get; } Microsoft.OpenApi.Models.ParameterStyle? Style { get; } } public interface IOpenApiLink : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement { - string OperationId { get; } - string OperationRef { get; } - System.Collections.Generic.IDictionary Parameters { get; } - Microsoft.OpenApi.Models.RuntimeExpressionAnyWrapper RequestBody { get; } - Microsoft.OpenApi.Models.OpenApiServer Server { get; } + string? OperationId { get; } + string? OperationRef { get; } + System.Collections.Generic.IDictionary? Parameters { get; } + Microsoft.OpenApi.Models.RuntimeExpressionAnyWrapper? RequestBody { get; } + Microsoft.OpenApi.Models.OpenApiServer? Server { get; } } public interface IOpenApiParameter : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement { bool AllowEmptyValue { get; } bool AllowReserved { get; } - System.Collections.Generic.IDictionary Content { get; } + System.Collections.Generic.IDictionary? Content { get; } bool Deprecated { get; } - System.Text.Json.Nodes.JsonNode Example { get; } - System.Collections.Generic.IDictionary Examples { get; } + System.Text.Json.Nodes.JsonNode? Example { get; } + System.Collections.Generic.IDictionary? Examples { get; } bool Explode { get; } Microsoft.OpenApi.Models.ParameterLocation? In { get; } - string Name { get; } + string? Name { get; } bool Required { get; } - Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema Schema { get; } + Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema? Schema { get; } Microsoft.OpenApi.Models.ParameterStyle? Style { get; } } public interface IOpenApiPathItem : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiSummarizedElement { - System.Collections.Generic.IDictionary Operations { get; } - System.Collections.Generic.IList Parameters { get; } - System.Collections.Generic.IList Servers { get; } + System.Collections.Generic.IDictionary? Operations { get; } + System.Collections.Generic.IList? Parameters { get; } + System.Collections.Generic.IList? Servers { get; } } public interface IOpenApiReadOnlyDescribedElement : Microsoft.OpenApi.Interfaces.IOpenApiElement { - string Description { get; } + string? Description { get; } } public interface IOpenApiRequestBody : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement { - System.Collections.Generic.IDictionary Content { get; } + System.Collections.Generic.IDictionary? Content { get; } bool Required { get; } - Microsoft.OpenApi.Models.Interfaces.IOpenApiParameter ConvertToBodyParameter(Microsoft.OpenApi.Writers.IOpenApiWriter writer); - System.Collections.Generic.IEnumerable ConvertToFormDataParameters(Microsoft.OpenApi.Writers.IOpenApiWriter writer); + Microsoft.OpenApi.Models.Interfaces.IOpenApiParameter? ConvertToBodyParameter(Microsoft.OpenApi.Writers.IOpenApiWriter writer); + System.Collections.Generic.IEnumerable? ConvertToFormDataParameters(Microsoft.OpenApi.Writers.IOpenApiWriter writer); } public interface IOpenApiResponse : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement { - System.Collections.Generic.IDictionary Content { get; } - System.Collections.Generic.IDictionary Headers { get; } - System.Collections.Generic.IDictionary Links { get; } + System.Collections.Generic.IDictionary? Content { get; } + System.Collections.Generic.IDictionary? Headers { get; } + System.Collections.Generic.IDictionary? Links { get; } } public interface IOpenApiSchema : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement { - Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema AdditionalProperties { get; } + Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema? AdditionalProperties { get; } bool AdditionalPropertiesAllowed { get; } - System.Collections.Generic.IList AllOf { get; } - System.Collections.Generic.IDictionary Annotations { get; } - System.Collections.Generic.IList AnyOf { get; } - string Comment { get; } - string Const { get; } - System.Text.Json.Nodes.JsonNode Default { get; } - System.Collections.Generic.IDictionary Definitions { get; } - System.Collections.Generic.IDictionary> DependentRequired { get; } + System.Collections.Generic.IList? AllOf { get; } + System.Collections.Generic.IDictionary? Annotations { get; } + System.Collections.Generic.IList? AnyOf { get; } + string? Comment { get; } + string? Const { get; } + System.Text.Json.Nodes.JsonNode? Default { get; } + System.Collections.Generic.IDictionary? Definitions { get; } + System.Collections.Generic.IDictionary>? DependentRequired { get; } bool Deprecated { get; } - Microsoft.OpenApi.Models.OpenApiDiscriminator Discriminator { get; } - string DynamicAnchor { get; } - string DynamicRef { get; } - System.Collections.Generic.IList Enum { get; } - System.Text.Json.Nodes.JsonNode Example { get; } - System.Collections.Generic.IList Examples { get; } + Microsoft.OpenApi.Models.OpenApiDiscriminator? Discriminator { get; } + string? DynamicAnchor { get; } + string? DynamicRef { get; } + System.Collections.Generic.IList? Enum { get; } + System.Text.Json.Nodes.JsonNode? Example { get; } + System.Collections.Generic.IList? Examples { get; } decimal? ExclusiveMaximum { get; } decimal? ExclusiveMinimum { get; } - Microsoft.OpenApi.Models.OpenApiExternalDocs ExternalDocs { get; } - string Format { get; } - string Id { get; } - Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema Items { get; } + Microsoft.OpenApi.Models.OpenApiExternalDocs? ExternalDocs { get; } + string? Format { get; } + string? Id { get; } + Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema? Items { get; } int? MaxItems { get; } int? MaxLength { get; } int? MaxProperties { get; } @@ -445,42 +444,42 @@ namespace Microsoft.OpenApi.Models.Interfaces int? MinProperties { get; } decimal? Minimum { get; } decimal? MultipleOf { get; } - Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema Not { get; } - System.Collections.Generic.IList OneOf { get; } - string Pattern { get; } - System.Collections.Generic.IDictionary PatternProperties { get; } - System.Collections.Generic.IDictionary Properties { get; } + Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema? Not { get; } + System.Collections.Generic.IList? OneOf { get; } + string? Pattern { get; } + System.Collections.Generic.IDictionary? PatternProperties { get; } + System.Collections.Generic.IDictionary? Properties { get; } bool ReadOnly { get; } - System.Collections.Generic.ISet Required { get; } - System.Uri Schema { get; } - string Title { get; } + System.Collections.Generic.ISet? Required { get; } + System.Uri? Schema { get; } + string? Title { get; } Microsoft.OpenApi.Models.JsonSchemaType? Type { get; } bool UnEvaluatedProperties { get; } bool UnevaluatedProperties { get; } bool? UniqueItems { get; } - System.Collections.Generic.IDictionary UnrecognizedKeywords { get; } - System.Collections.Generic.IDictionary Vocabulary { get; } + System.Collections.Generic.IDictionary? UnrecognizedKeywords { get; } + System.Collections.Generic.IDictionary? Vocabulary { get; } bool WriteOnly { get; } - Microsoft.OpenApi.Models.OpenApiXml Xml { get; } + Microsoft.OpenApi.Models.OpenApiXml? Xml { get; } } public interface IOpenApiSecurityScheme : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement { - string BearerFormat { get; } - Microsoft.OpenApi.Models.OpenApiOAuthFlows Flows { get; } + string? BearerFormat { get; } + Microsoft.OpenApi.Models.OpenApiOAuthFlows? Flows { get; } Microsoft.OpenApi.Models.ParameterLocation? In { get; } - string Name { get; } - System.Uri OpenIdConnectUrl { get; } - string Scheme { get; } + string? Name { get; } + System.Uri? OpenIdConnectUrl { get; } + string? Scheme { get; } Microsoft.OpenApi.Models.SecuritySchemeType? Type { get; } } public interface IOpenApiSummarizedElement : Microsoft.OpenApi.Interfaces.IOpenApiElement { - string Summary { get; set; } + string? Summary { get; set; } } public interface IOpenApiTag : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiReadOnlyDescribedElement { - Microsoft.OpenApi.Models.OpenApiExternalDocs ExternalDocs { get; } - string Name { get; } + Microsoft.OpenApi.Models.OpenApiExternalDocs? ExternalDocs { get; } + string? Name { get; } } } namespace Microsoft.OpenApi.Models @@ -499,8 +498,8 @@ namespace Microsoft.OpenApi.Models public class OpenApiCallback : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiCallback { public OpenApiCallback() { } - public System.Collections.Generic.IDictionary Extensions { get; set; } - public System.Collections.Generic.Dictionary PathItems { get; set; } + public System.Collections.Generic.IDictionary? Extensions { get; set; } + public System.Collections.Generic.Dictionary? PathItems { get; set; } public void AddPathItem(Microsoft.OpenApi.Expressions.RuntimeExpression expression, Microsoft.OpenApi.Models.Interfaces.IOpenApiPathItem pathItem) { } public Microsoft.OpenApi.Models.Interfaces.IOpenApiCallback CreateShallowCopy() { } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -688,10 +687,10 @@ namespace Microsoft.OpenApi.Models { public OpenApiContact() { } public OpenApiContact(Microsoft.OpenApi.Models.OpenApiContact contact) { } - public string Email { get; set; } - public System.Collections.Generic.IDictionary Extensions { get; set; } - public string Name { get; set; } - public System.Uri Url { get; set; } + public string? Email { get; set; } + public System.Collections.Generic.IDictionary? Extensions { get; set; } + public string? Name { get; set; } + public System.Uri? Url { get; set; } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -700,9 +699,9 @@ namespace Microsoft.OpenApi.Models { public OpenApiDiscriminator() { } public OpenApiDiscriminator(Microsoft.OpenApi.Models.OpenApiDiscriminator discriminator) { } - public System.Collections.Generic.IDictionary Extensions { get; set; } - public System.Collections.Generic.IDictionary Mapping { get; set; } - public string PropertyName { get; set; } + public System.Collections.Generic.IDictionary? Extensions { get; set; } + public System.Collections.Generic.IDictionary? Mapping { get; set; } + public string? PropertyName { get; set; } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -742,10 +741,10 @@ namespace Microsoft.OpenApi.Models public OpenApiEncoding() { } public OpenApiEncoding(Microsoft.OpenApi.Models.OpenApiEncoding encoding) { } public bool? AllowReserved { get; set; } - public string ContentType { get; set; } + public string? ContentType { get; set; } public bool? Explode { get; set; } - public System.Collections.Generic.IDictionary Extensions { get; set; } - public System.Collections.Generic.IDictionary Headers { get; set; } + public System.Collections.Generic.IDictionary? Extensions { get; set; } + public System.Collections.Generic.IDictionary? Headers { get; set; } public Microsoft.OpenApi.Models.ParameterStyle? Style { get; set; } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -755,19 +754,19 @@ namespace Microsoft.OpenApi.Models { public OpenApiError(Microsoft.OpenApi.Exceptions.OpenApiException exception) { } public OpenApiError(Microsoft.OpenApi.Models.OpenApiError error) { } - public OpenApiError(string pointer, string message) { } + public OpenApiError(string? pointer, string message) { } public string Message { get; set; } - public string Pointer { get; set; } + public string? Pointer { get; set; } public override string ToString() { } } public class OpenApiExample : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiExample, Microsoft.OpenApi.Models.Interfaces.IOpenApiSummarizedElement { public OpenApiExample() { } - public string Description { get; set; } - public System.Collections.Generic.IDictionary Extensions { get; set; } - public string ExternalValue { get; set; } - public string Summary { get; set; } - public System.Text.Json.Nodes.JsonNode Value { get; set; } + public string? Description { get; set; } + public System.Collections.Generic.IDictionary? Extensions { get; set; } + public string? ExternalValue { get; set; } + public string? Summary { get; set; } + public System.Text.Json.Nodes.JsonNode? Value { get; set; } public Microsoft.OpenApi.Models.Interfaces.IOpenApiExample CreateShallowCopy() { } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -777,8 +776,8 @@ namespace Microsoft.OpenApi.Models where T : Microsoft.OpenApi.Interfaces.IOpenApiSerializable { protected OpenApiExtensibleDictionary() { } - protected OpenApiExtensibleDictionary(System.Collections.Generic.Dictionary dictionary, System.Collections.Generic.IDictionary extensions = null) { } - public System.Collections.Generic.IDictionary Extensions { get; set; } + protected OpenApiExtensibleDictionary(System.Collections.Generic.Dictionary dictionary, System.Collections.Generic.IDictionary? extensions = null) { } + public System.Collections.Generic.IDictionary? Extensions { get; set; } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -787,9 +786,9 @@ namespace Microsoft.OpenApi.Models { public OpenApiExternalDocs() { } public OpenApiExternalDocs(Microsoft.OpenApi.Models.OpenApiExternalDocs externalDocs) { } - public string Description { get; set; } - public System.Collections.Generic.IDictionary Extensions { get; set; } - public System.Uri Url { get; set; } + public string? Description { get; set; } + public System.Collections.Generic.IDictionary? Extensions { get; set; } + public System.Uri? Url { get; set; } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -799,15 +798,15 @@ namespace Microsoft.OpenApi.Models public OpenApiHeader() { } public bool AllowEmptyValue { get; set; } public bool AllowReserved { get; set; } - public System.Collections.Generic.IDictionary Content { get; set; } + public System.Collections.Generic.IDictionary? Content { get; set; } public bool Deprecated { get; set; } - public string Description { get; set; } - public System.Text.Json.Nodes.JsonNode Example { get; set; } - public System.Collections.Generic.IDictionary Examples { get; set; } + public string? Description { get; set; } + public System.Text.Json.Nodes.JsonNode? Example { get; set; } + public System.Collections.Generic.IDictionary? Examples { get; set; } public bool Explode { get; set; } - public System.Collections.Generic.IDictionary Extensions { get; set; } + public System.Collections.Generic.IDictionary? Extensions { get; set; } public bool Required { get; set; } - public Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema Schema { get; set; } + public Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema? Schema { get; set; } public Microsoft.OpenApi.Models.ParameterStyle? Style { get; set; } public Microsoft.OpenApi.Models.Interfaces.IOpenApiHeader CreateShallowCopy() { } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -818,14 +817,14 @@ namespace Microsoft.OpenApi.Models { public OpenApiInfo() { } public OpenApiInfo(Microsoft.OpenApi.Models.OpenApiInfo info) { } - public Microsoft.OpenApi.Models.OpenApiContact Contact { get; set; } - public string Description { get; set; } - public System.Collections.Generic.IDictionary Extensions { get; set; } - public Microsoft.OpenApi.Models.OpenApiLicense License { get; set; } - public string Summary { get; set; } - public System.Uri TermsOfService { get; set; } - public string Title { get; set; } - public string Version { get; set; } + public Microsoft.OpenApi.Models.OpenApiContact? Contact { get; set; } + public string? Description { get; set; } + public System.Collections.Generic.IDictionary? Extensions { get; set; } + public Microsoft.OpenApi.Models.OpenApiLicense? License { get; set; } + public string? Summary { get; set; } + public System.Uri? TermsOfService { get; set; } + public string? Title { get; set; } + public string? Version { get; set; } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -834,10 +833,10 @@ namespace Microsoft.OpenApi.Models { public OpenApiLicense() { } public OpenApiLicense(Microsoft.OpenApi.Models.OpenApiLicense license) { } - public System.Collections.Generic.IDictionary Extensions { get; set; } - public string Identifier { get; set; } - public string Name { get; set; } - public System.Uri Url { get; set; } + public System.Collections.Generic.IDictionary? Extensions { get; set; } + public string? Identifier { get; set; } + public string? Name { get; set; } + public System.Uri? Url { get; set; } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -845,13 +844,13 @@ namespace Microsoft.OpenApi.Models public class OpenApiLink : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiLink { public OpenApiLink() { } - public string Description { get; set; } - public System.Collections.Generic.IDictionary Extensions { get; set; } - public string OperationId { get; set; } - public string OperationRef { get; set; } - public System.Collections.Generic.IDictionary Parameters { get; set; } - public Microsoft.OpenApi.Models.RuntimeExpressionAnyWrapper RequestBody { get; set; } - public Microsoft.OpenApi.Models.OpenApiServer Server { get; set; } + public string? Description { get; set; } + public System.Collections.Generic.IDictionary? Extensions { get; set; } + public string? OperationId { get; set; } + public string? OperationRef { get; set; } + public System.Collections.Generic.IDictionary? Parameters { get; set; } + public Microsoft.OpenApi.Models.RuntimeExpressionAnyWrapper? RequestBody { get; set; } + public Microsoft.OpenApi.Models.OpenApiServer? Server { get; set; } public Microsoft.OpenApi.Models.Interfaces.IOpenApiLink CreateShallowCopy() { } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -874,11 +873,11 @@ namespace Microsoft.OpenApi.Models { public OpenApiOAuthFlow() { } public OpenApiOAuthFlow(Microsoft.OpenApi.Models.OpenApiOAuthFlow oAuthFlow) { } - public System.Uri AuthorizationUrl { get; set; } - public System.Collections.Generic.IDictionary Extensions { get; set; } - public System.Uri RefreshUrl { get; set; } - public System.Collections.Generic.IDictionary Scopes { get; set; } - public System.Uri TokenUrl { get; set; } + public System.Uri? AuthorizationUrl { get; set; } + public System.Collections.Generic.IDictionary? Extensions { get; set; } + public System.Uri? RefreshUrl { get; set; } + public System.Collections.Generic.IDictionary? Scopes { get; set; } + public System.Uri? TokenUrl { get; set; } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -887,11 +886,11 @@ namespace Microsoft.OpenApi.Models { public OpenApiOAuthFlows() { } public OpenApiOAuthFlows(Microsoft.OpenApi.Models.OpenApiOAuthFlows oAuthFlows) { } - public Microsoft.OpenApi.Models.OpenApiOAuthFlow AuthorizationCode { get; set; } - public Microsoft.OpenApi.Models.OpenApiOAuthFlow ClientCredentials { get; set; } - public System.Collections.Generic.IDictionary Extensions { get; set; } - public Microsoft.OpenApi.Models.OpenApiOAuthFlow Implicit { get; set; } - public Microsoft.OpenApi.Models.OpenApiOAuthFlow Password { get; set; } + public Microsoft.OpenApi.Models.OpenApiOAuthFlow? AuthorizationCode { get; set; } + public Microsoft.OpenApi.Models.OpenApiOAuthFlow? ClientCredentials { get; set; } + public System.Collections.Generic.IDictionary? Extensions { get; set; } + public Microsoft.OpenApi.Models.OpenApiOAuthFlow? Implicit { get; set; } + public Microsoft.OpenApi.Models.OpenApiOAuthFlow? Password { get; set; } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -924,17 +923,17 @@ namespace Microsoft.OpenApi.Models public OpenApiParameter() { } public bool AllowEmptyValue { get; set; } public bool AllowReserved { get; set; } - public System.Collections.Generic.IDictionary Content { get; set; } + public System.Collections.Generic.IDictionary? Content { get; set; } public bool Deprecated { get; set; } - public string Description { get; set; } - public System.Text.Json.Nodes.JsonNode Example { get; set; } - public System.Collections.Generic.IDictionary Examples { get; set; } + public string? Description { get; set; } + public System.Text.Json.Nodes.JsonNode? Example { get; set; } + public System.Collections.Generic.IDictionary? Examples { get; set; } public bool Explode { get; set; } - public System.Collections.Generic.IDictionary Extensions { get; set; } + public System.Collections.Generic.IDictionary? Extensions { get; set; } public Microsoft.OpenApi.Models.ParameterLocation? In { get; set; } - public string Name { get; set; } + public string? Name { get; set; } public bool Required { get; set; } - public Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema Schema { get; set; } + public Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema? Schema { get; set; } public Microsoft.OpenApi.Models.ParameterStyle? Style { get; set; } public Microsoft.OpenApi.Models.Interfaces.IOpenApiParameter CreateShallowCopy() { } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -944,12 +943,12 @@ namespace Microsoft.OpenApi.Models public class OpenApiPathItem : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiPathItem, Microsoft.OpenApi.Models.Interfaces.IOpenApiSummarizedElement { public OpenApiPathItem() { } - public string Description { get; set; } - public System.Collections.Generic.IDictionary Extensions { get; set; } - public System.Collections.Generic.IDictionary Operations { get; set; } - public System.Collections.Generic.IList Parameters { get; set; } - public System.Collections.Generic.IList Servers { get; set; } - public string Summary { get; set; } + public string? Description { get; set; } + public System.Collections.Generic.IDictionary? Extensions { get; set; } + public System.Collections.Generic.IDictionary? Operations { get; set; } + public System.Collections.Generic.IList? Parameters { get; set; } + public System.Collections.Generic.IList? Servers { get; set; } + public string? Summary { get; set; } public void AddOperation(System.Net.Http.HttpMethod operationType, Microsoft.OpenApi.Models.OpenApiOperation operation) { } public Microsoft.OpenApi.Models.Interfaces.IOpenApiPathItem CreateShallowCopy() { } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -965,17 +964,17 @@ namespace Microsoft.OpenApi.Models { public OpenApiReference() { } public OpenApiReference(Microsoft.OpenApi.Models.OpenApiReference reference) { } - public string Description { get; set; } - public string ExternalResource { get; init; } - public Microsoft.OpenApi.Models.OpenApiDocument HostDocument { get; init; } - public string Id { get; init; } + public string? Description { get; set; } + public string? ExternalResource { get; init; } + public Microsoft.OpenApi.Models.OpenApiDocument? HostDocument { get; init; } + public string? Id { get; init; } public bool IsExternal { get; } public bool IsFragment { get; init; } public bool IsLocal { get; } - public string ReferenceV2 { get; } - public string ReferenceV3 { get; } - public string Summary { get; set; } - public Microsoft.OpenApi.Models.ReferenceType? Type { get; init; } + public string? ReferenceV2 { get; } + public string? ReferenceV3 { get; } + public string? Summary { get; set; } + public Microsoft.OpenApi.Models.ReferenceType Type { get; init; } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -983,9 +982,9 @@ namespace Microsoft.OpenApi.Models public class OpenApiRequestBody : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiRequestBody { public OpenApiRequestBody() { } - public System.Collections.Generic.IDictionary Content { get; set; } - public string Description { get; set; } - public System.Collections.Generic.IDictionary Extensions { get; set; } + public System.Collections.Generic.IDictionary? Content { get; set; } + public string? Description { get; set; } + public System.Collections.Generic.IDictionary? Extensions { get; set; } public bool Required { get; set; } public Microsoft.OpenApi.Models.Interfaces.IOpenApiParameter ConvertToBodyParameter(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public System.Collections.Generic.IEnumerable ConvertToFormDataParameters(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -997,11 +996,11 @@ namespace Microsoft.OpenApi.Models public class OpenApiResponse : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiResponse { public OpenApiResponse() { } - public System.Collections.Generic.IDictionary Content { get; set; } - public string Description { get; set; } - public System.Collections.Generic.IDictionary Extensions { get; set; } - public System.Collections.Generic.IDictionary Headers { get; set; } - public System.Collections.Generic.IDictionary Links { get; set; } + public System.Collections.Generic.IDictionary? Content { get; set; } + public string? Description { get; set; } + public System.Collections.Generic.IDictionary? Extensions { get; set; } + public System.Collections.Generic.IDictionary? Headers { get; set; } + public System.Collections.Generic.IDictionary? Links { get; set; } public Microsoft.OpenApi.Models.Interfaces.IOpenApiResponse CreateShallowCopy() { } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -1015,31 +1014,31 @@ namespace Microsoft.OpenApi.Models public class OpenApiSchema : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema { public OpenApiSchema() { } - public Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema AdditionalProperties { get; set; } + public Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema? AdditionalProperties { get; set; } public bool AdditionalPropertiesAllowed { get; set; } - public System.Collections.Generic.IList AllOf { get; set; } - public System.Collections.Generic.IDictionary Annotations { get; set; } - public System.Collections.Generic.IList AnyOf { get; set; } - public string Comment { get; set; } - public string Const { get; set; } - public System.Text.Json.Nodes.JsonNode Default { get; set; } - public System.Collections.Generic.IDictionary Definitions { get; set; } - public System.Collections.Generic.IDictionary> DependentRequired { get; set; } + public System.Collections.Generic.IList? AllOf { get; set; } + public System.Collections.Generic.IDictionary? Annotations { get; set; } + public System.Collections.Generic.IList? AnyOf { get; set; } + public string? Comment { get; set; } + public string? Const { get; set; } + public System.Text.Json.Nodes.JsonNode? Default { get; set; } + public System.Collections.Generic.IDictionary? Definitions { get; set; } + public System.Collections.Generic.IDictionary>? DependentRequired { get; set; } public bool Deprecated { get; set; } - public string Description { get; set; } - public Microsoft.OpenApi.Models.OpenApiDiscriminator Discriminator { get; set; } - public string DynamicAnchor { get; set; } - public string DynamicRef { get; set; } - public System.Collections.Generic.IList Enum { get; set; } - public System.Text.Json.Nodes.JsonNode Example { get; set; } - public System.Collections.Generic.IList Examples { get; set; } + public string? Description { get; set; } + public Microsoft.OpenApi.Models.OpenApiDiscriminator? Discriminator { get; set; } + public string? DynamicAnchor { get; set; } + public string? DynamicRef { get; set; } + public System.Collections.Generic.IList? Enum { get; set; } + public System.Text.Json.Nodes.JsonNode? Example { get; set; } + public System.Collections.Generic.IList? Examples { get; set; } public decimal? ExclusiveMaximum { get; set; } public decimal? ExclusiveMinimum { get; set; } - public System.Collections.Generic.IDictionary Extensions { get; set; } - public Microsoft.OpenApi.Models.OpenApiExternalDocs ExternalDocs { get; set; } - public string Format { get; set; } - public string Id { get; set; } - public Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema Items { get; set; } + public System.Collections.Generic.IDictionary? Extensions { get; set; } + public Microsoft.OpenApi.Models.OpenApiExternalDocs? ExternalDocs { get; set; } + public string? Format { get; set; } + public string? Id { get; set; } + public Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema? Items { get; set; } public int? MaxItems { get; set; } public int? MaxLength { get; set; } public int? MaxProperties { get; set; } @@ -1049,23 +1048,23 @@ namespace Microsoft.OpenApi.Models public int? MinProperties { get; set; } public decimal? Minimum { get; set; } public decimal? MultipleOf { get; set; } - public Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema Not { get; set; } - public System.Collections.Generic.IList OneOf { get; set; } - public string Pattern { get; set; } - public System.Collections.Generic.IDictionary PatternProperties { get; set; } - public System.Collections.Generic.IDictionary Properties { get; set; } + public Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema? Not { get; set; } + public System.Collections.Generic.IList? OneOf { get; set; } + public string? Pattern { get; set; } + public System.Collections.Generic.IDictionary? PatternProperties { get; set; } + public System.Collections.Generic.IDictionary? Properties { get; set; } public bool ReadOnly { get; set; } - public System.Collections.Generic.ISet Required { get; set; } - public System.Uri Schema { get; set; } - public string Title { get; set; } + public System.Collections.Generic.ISet? Required { get; set; } + public System.Uri? Schema { get; set; } + public string? Title { get; set; } public Microsoft.OpenApi.Models.JsonSchemaType? Type { get; set; } public bool UnEvaluatedProperties { get; set; } public bool UnevaluatedProperties { get; set; } public bool? UniqueItems { get; set; } - public System.Collections.Generic.IDictionary UnrecognizedKeywords { get; set; } - public System.Collections.Generic.IDictionary Vocabulary { get; set; } + public System.Collections.Generic.IDictionary? UnrecognizedKeywords { get; set; } + public System.Collections.Generic.IDictionary? Vocabulary { get; set; } public bool WriteOnly { get; set; } - public Microsoft.OpenApi.Models.OpenApiXml Xml { get; set; } + public Microsoft.OpenApi.Models.OpenApiXml? Xml { get; set; } public Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema CreateShallowCopy() { } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -1081,14 +1080,14 @@ namespace Microsoft.OpenApi.Models public class OpenApiSecurityScheme : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiSecurityScheme { public OpenApiSecurityScheme() { } - public string BearerFormat { get; set; } - public string Description { get; set; } - public System.Collections.Generic.IDictionary Extensions { get; set; } - public Microsoft.OpenApi.Models.OpenApiOAuthFlows Flows { get; set; } + public string? BearerFormat { get; set; } + public string? Description { get; set; } + public System.Collections.Generic.IDictionary? Extensions { get; set; } + public Microsoft.OpenApi.Models.OpenApiOAuthFlows? Flows { get; set; } public Microsoft.OpenApi.Models.ParameterLocation? In { get; set; } - public string Name { get; set; } - public System.Uri OpenIdConnectUrl { get; set; } - public string Scheme { get; set; } + public string? Name { get; set; } + public System.Uri? OpenIdConnectUrl { get; set; } + public string? Scheme { get; set; } public Microsoft.OpenApi.Models.SecuritySchemeType? Type { get; set; } public Microsoft.OpenApi.Models.Interfaces.IOpenApiSecurityScheme CreateShallowCopy() { } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -1099,10 +1098,10 @@ namespace Microsoft.OpenApi.Models { public OpenApiServer() { } public OpenApiServer(Microsoft.OpenApi.Models.OpenApiServer server) { } - public string Description { get; set; } - public System.Collections.Generic.IDictionary Extensions { get; set; } - public string Url { get; set; } - public System.Collections.Generic.IDictionary Variables { get; set; } + public string? Description { get; set; } + public System.Collections.Generic.IDictionary? Extensions { get; set; } + public string? Url { get; set; } + public System.Collections.Generic.IDictionary? Variables { get; set; } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -1111,10 +1110,10 @@ namespace Microsoft.OpenApi.Models { public OpenApiServerVariable() { } public OpenApiServerVariable(Microsoft.OpenApi.Models.OpenApiServerVariable serverVariable) { } - public string Default { get; set; } - public string Description { get; set; } - public System.Collections.Generic.List Enum { get; set; } - public System.Collections.Generic.IDictionary Extensions { get; set; } + public string? Default { get; set; } + public string? Description { get; set; } + public System.Collections.Generic.List? Enum { get; set; } + public System.Collections.Generic.IDictionary? Extensions { get; set; } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -1122,10 +1121,10 @@ namespace Microsoft.OpenApi.Models public class OpenApiTag : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiReadOnlyDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiTag { public OpenApiTag() { } - public string Description { get; set; } - public System.Collections.Generic.IDictionary Extensions { get; set; } - public Microsoft.OpenApi.Models.OpenApiExternalDocs ExternalDocs { get; set; } - public string Name { get; set; } + public string? Description { get; set; } + public System.Collections.Generic.IDictionary? Extensions { get; set; } + public Microsoft.OpenApi.Models.OpenApiExternalDocs? ExternalDocs { get; set; } + public string? Name { get; set; } public Microsoft.OpenApi.Models.Interfaces.IOpenApiTag CreateShallowCopy() { } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -1136,10 +1135,10 @@ namespace Microsoft.OpenApi.Models public OpenApiXml() { } public OpenApiXml(Microsoft.OpenApi.Models.OpenApiXml xml) { } public bool Attribute { get; set; } - public System.Collections.Generic.IDictionary Extensions { get; set; } - public string Name { get; set; } - public System.Uri Namespace { get; set; } - public string Prefix { get; set; } + public System.Collections.Generic.IDictionary? Extensions { get; set; } + public string? Name { get; set; } + public System.Uri? Namespace { get; set; } + public string? Prefix { get; set; } public bool Wrapped { get; set; } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -1202,8 +1201,8 @@ namespace Microsoft.OpenApi.Models { public RuntimeExpressionAnyWrapper() { } public RuntimeExpressionAnyWrapper(Microsoft.OpenApi.Models.RuntimeExpressionAnyWrapper runtimeExpressionAnyWrapper) { } - public System.Text.Json.Nodes.JsonNode Any { get; set; } - public Microsoft.OpenApi.Expressions.RuntimeExpression Expression { get; set; } + public System.Text.Json.Nodes.JsonNode? Any { get; set; } + public Microsoft.OpenApi.Expressions.RuntimeExpression? Expression { get; set; } public void WriteValue(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } } public enum SecuritySchemeType @@ -1225,7 +1224,7 @@ namespace Microsoft.OpenApi.Models.References where V : Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { protected BaseOpenApiReferenceHolder(Microsoft.OpenApi.Models.References.BaseOpenApiReferenceHolder source) { } - protected BaseOpenApiReferenceHolder(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument hostDocument, Microsoft.OpenApi.Models.ReferenceType referenceType, string externalResource) { } + protected BaseOpenApiReferenceHolder(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument? hostDocument, Microsoft.OpenApi.Models.ReferenceType referenceType, string? externalResource) { } public T RecursiveTarget { get; } public Microsoft.OpenApi.Models.OpenApiReference Reference { get; init; } public virtual V Target { get; } @@ -1237,142 +1236,142 @@ namespace Microsoft.OpenApi.Models.References } public class OpenApiCallbackReference : Microsoft.OpenApi.Models.References.BaseOpenApiReferenceHolder, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiCallback { - public OpenApiCallbackReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument hostDocument = null, string externalResource = null) { } - public System.Collections.Generic.IDictionary Extensions { get; } - public System.Collections.Generic.Dictionary PathItems { get; } + public OpenApiCallbackReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument? hostDocument = null, string? externalResource = null) { } + public System.Collections.Generic.IDictionary? Extensions { get; } + public System.Collections.Generic.Dictionary? PathItems { get; } public override Microsoft.OpenApi.Models.Interfaces.IOpenApiCallback CopyReferenceAsTargetElementWithOverrides(Microsoft.OpenApi.Models.Interfaces.IOpenApiCallback source) { } public Microsoft.OpenApi.Models.Interfaces.IOpenApiCallback CreateShallowCopy() { } public override void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } } public class OpenApiExampleReference : Microsoft.OpenApi.Models.References.BaseOpenApiReferenceHolder, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiExample, Microsoft.OpenApi.Models.Interfaces.IOpenApiSummarizedElement { - public OpenApiExampleReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument hostDocument = null, string externalResource = null) { } - public string Description { get; set; } - public System.Collections.Generic.IDictionary Extensions { get; } - public string ExternalValue { get; } - public string Summary { get; set; } - public System.Text.Json.Nodes.JsonNode Value { get; } + public OpenApiExampleReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument? hostDocument = null, string? externalResource = null) { } + public string? Description { get; set; } + public System.Collections.Generic.IDictionary? Extensions { get; } + public string? ExternalValue { get; } + public string? Summary { get; set; } + public System.Text.Json.Nodes.JsonNode? Value { get; } public override Microsoft.OpenApi.Models.Interfaces.IOpenApiExample CopyReferenceAsTargetElementWithOverrides(Microsoft.OpenApi.Models.Interfaces.IOpenApiExample source) { } public Microsoft.OpenApi.Models.Interfaces.IOpenApiExample CreateShallowCopy() { } public override void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } } public class OpenApiHeaderReference : Microsoft.OpenApi.Models.References.BaseOpenApiReferenceHolder, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiHeader { - public OpenApiHeaderReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument hostDocument = null, string externalResource = null) { } + public OpenApiHeaderReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument? hostDocument = null, string? externalResource = null) { } public bool AllowEmptyValue { get; } public bool AllowReserved { get; } - public System.Collections.Generic.IDictionary Content { get; } + public System.Collections.Generic.IDictionary? Content { get; } public bool Deprecated { get; } - public string Description { get; set; } - public System.Text.Json.Nodes.JsonNode Example { get; } - public System.Collections.Generic.IDictionary Examples { get; } + public string? Description { get; set; } + public System.Text.Json.Nodes.JsonNode? Example { get; } + public System.Collections.Generic.IDictionary? Examples { get; } public bool Explode { get; } - public System.Collections.Generic.IDictionary Extensions { get; } + public System.Collections.Generic.IDictionary? Extensions { get; } public bool Required { get; } - public Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema Schema { get; } + public Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema? Schema { get; } public Microsoft.OpenApi.Models.ParameterStyle? Style { get; } public override Microsoft.OpenApi.Models.Interfaces.IOpenApiHeader CopyReferenceAsTargetElementWithOverrides(Microsoft.OpenApi.Models.Interfaces.IOpenApiHeader source) { } public Microsoft.OpenApi.Models.Interfaces.IOpenApiHeader CreateShallowCopy() { } } public class OpenApiLinkReference : Microsoft.OpenApi.Models.References.BaseOpenApiReferenceHolder, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiLink { - public OpenApiLinkReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument hostDocument = null, string externalResource = null) { } - public string Description { get; set; } - public System.Collections.Generic.IDictionary Extensions { get; } - public string OperationId { get; } - public string OperationRef { get; } - public System.Collections.Generic.IDictionary Parameters { get; } - public Microsoft.OpenApi.Models.RuntimeExpressionAnyWrapper RequestBody { get; } - public Microsoft.OpenApi.Models.OpenApiServer Server { get; } + public OpenApiLinkReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument? hostDocument = null, string? externalResource = null) { } + public string? Description { get; set; } + public System.Collections.Generic.IDictionary? Extensions { get; } + public string? OperationId { get; } + public string? OperationRef { get; } + public System.Collections.Generic.IDictionary? Parameters { get; } + public Microsoft.OpenApi.Models.RuntimeExpressionAnyWrapper? RequestBody { get; } + public Microsoft.OpenApi.Models.OpenApiServer? Server { get; } public override Microsoft.OpenApi.Models.Interfaces.IOpenApiLink CopyReferenceAsTargetElementWithOverrides(Microsoft.OpenApi.Models.Interfaces.IOpenApiLink source) { } public Microsoft.OpenApi.Models.Interfaces.IOpenApiLink CreateShallowCopy() { } public override void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } } public class OpenApiParameterReference : Microsoft.OpenApi.Models.References.BaseOpenApiReferenceHolder, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiParameter { - public OpenApiParameterReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument hostDocument = null, string externalResource = null) { } + public OpenApiParameterReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument? hostDocument = null, string? externalResource = null) { } public bool AllowEmptyValue { get; } public bool AllowReserved { get; } - public System.Collections.Generic.IDictionary Content { get; } + public System.Collections.Generic.IDictionary? Content { get; } public bool Deprecated { get; } - public string Description { get; set; } - public System.Text.Json.Nodes.JsonNode Example { get; } - public System.Collections.Generic.IDictionary Examples { get; } + public string? Description { get; set; } + public System.Text.Json.Nodes.JsonNode? Example { get; } + public System.Collections.Generic.IDictionary? Examples { get; } public bool Explode { get; } - public System.Collections.Generic.IDictionary Extensions { get; } + public System.Collections.Generic.IDictionary? Extensions { get; } public Microsoft.OpenApi.Models.ParameterLocation? In { get; } - public string Name { get; } + public string? Name { get; } public bool Required { get; } - public Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema Schema { get; } + public Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema? Schema { get; } public Microsoft.OpenApi.Models.ParameterStyle? Style { get; } public override Microsoft.OpenApi.Models.Interfaces.IOpenApiParameter CopyReferenceAsTargetElementWithOverrides(Microsoft.OpenApi.Models.Interfaces.IOpenApiParameter source) { } public Microsoft.OpenApi.Models.Interfaces.IOpenApiParameter CreateShallowCopy() { } } public class OpenApiPathItemReference : Microsoft.OpenApi.Models.References.BaseOpenApiReferenceHolder, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiPathItem, Microsoft.OpenApi.Models.Interfaces.IOpenApiSummarizedElement { - public OpenApiPathItemReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument hostDocument = null, string externalResource = null) { } - public string Description { get; set; } - public System.Collections.Generic.IDictionary Extensions { get; } - public System.Collections.Generic.IDictionary Operations { get; } - public System.Collections.Generic.IList Parameters { get; } - public System.Collections.Generic.IList Servers { get; } - public string Summary { get; set; } + public OpenApiPathItemReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument? hostDocument = null, string? externalResource = null) { } + public string? Description { get; set; } + public System.Collections.Generic.IDictionary? Extensions { get; } + public System.Collections.Generic.IDictionary? Operations { get; } + public System.Collections.Generic.IList? Parameters { get; } + public System.Collections.Generic.IList? Servers { get; } + public string? Summary { get; set; } public override Microsoft.OpenApi.Models.Interfaces.IOpenApiPathItem CopyReferenceAsTargetElementWithOverrides(Microsoft.OpenApi.Models.Interfaces.IOpenApiPathItem source) { } public Microsoft.OpenApi.Models.Interfaces.IOpenApiPathItem CreateShallowCopy() { } public override void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } } public class OpenApiRequestBodyReference : Microsoft.OpenApi.Models.References.BaseOpenApiReferenceHolder, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiRequestBody { - public OpenApiRequestBodyReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument hostDocument = null, string externalResource = null) { } - public System.Collections.Generic.IDictionary Content { get; } - public string Description { get; set; } - public System.Collections.Generic.IDictionary Extensions { get; } + public OpenApiRequestBodyReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument? hostDocument = null, string? externalResource = null) { } + public System.Collections.Generic.IDictionary? Content { get; } + public string? Description { get; set; } + public System.Collections.Generic.IDictionary? Extensions { get; } public bool Required { get; } - public Microsoft.OpenApi.Models.Interfaces.IOpenApiParameter ConvertToBodyParameter(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } - public System.Collections.Generic.IEnumerable ConvertToFormDataParameters(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public Microsoft.OpenApi.Models.Interfaces.IOpenApiParameter? ConvertToBodyParameter(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public System.Collections.Generic.IEnumerable? ConvertToFormDataParameters(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public override Microsoft.OpenApi.Models.Interfaces.IOpenApiRequestBody CopyReferenceAsTargetElementWithOverrides(Microsoft.OpenApi.Models.Interfaces.IOpenApiRequestBody source) { } public Microsoft.OpenApi.Models.Interfaces.IOpenApiRequestBody CreateShallowCopy() { } public override void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } } public class OpenApiResponseReference : Microsoft.OpenApi.Models.References.BaseOpenApiReferenceHolder, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiResponse { - public OpenApiResponseReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument hostDocument = null, string externalResource = null) { } - public System.Collections.Generic.IDictionary Content { get; } - public string Description { get; set; } - public System.Collections.Generic.IDictionary Extensions { get; } - public System.Collections.Generic.IDictionary Headers { get; } - public System.Collections.Generic.IDictionary Links { get; } + public OpenApiResponseReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument? hostDocument = null, string? externalResource = null) { } + public System.Collections.Generic.IDictionary? Content { get; } + public string? Description { get; set; } + public System.Collections.Generic.IDictionary? Extensions { get; } + public System.Collections.Generic.IDictionary? Headers { get; } + public System.Collections.Generic.IDictionary? Links { get; } public override Microsoft.OpenApi.Models.Interfaces.IOpenApiResponse CopyReferenceAsTargetElementWithOverrides(Microsoft.OpenApi.Models.Interfaces.IOpenApiResponse source) { } public Microsoft.OpenApi.Models.Interfaces.IOpenApiResponse CreateShallowCopy() { } } public class OpenApiSchemaReference : Microsoft.OpenApi.Models.References.BaseOpenApiReferenceHolder, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema { - public OpenApiSchemaReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument hostDocument = null, string externalResource = null) { } - public Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema AdditionalProperties { get; } + public OpenApiSchemaReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument? hostDocument = null, string? externalResource = null) { } + public Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema? AdditionalProperties { get; } public bool AdditionalPropertiesAllowed { get; } - public System.Collections.Generic.IList AllOf { get; } - public System.Collections.Generic.IDictionary Annotations { get; } - public System.Collections.Generic.IList AnyOf { get; } - public string Comment { get; } - public string Const { get; } - public System.Text.Json.Nodes.JsonNode Default { get; } - public System.Collections.Generic.IDictionary Definitions { get; } - public System.Collections.Generic.IDictionary> DependentRequired { get; } + public System.Collections.Generic.IList? AllOf { get; } + public System.Collections.Generic.IDictionary? Annotations { get; } + public System.Collections.Generic.IList? AnyOf { get; } + public string? Comment { get; } + public string? Const { get; } + public System.Text.Json.Nodes.JsonNode? Default { get; } + public System.Collections.Generic.IDictionary? Definitions { get; } + public System.Collections.Generic.IDictionary>? DependentRequired { get; } public bool Deprecated { get; } - public string Description { get; set; } - public Microsoft.OpenApi.Models.OpenApiDiscriminator Discriminator { get; } - public string DynamicAnchor { get; } - public string DynamicRef { get; } - public System.Collections.Generic.IList Enum { get; } - public System.Text.Json.Nodes.JsonNode Example { get; } - public System.Collections.Generic.IList Examples { get; } + public string? Description { get; set; } + public Microsoft.OpenApi.Models.OpenApiDiscriminator? Discriminator { get; } + public string? DynamicAnchor { get; } + public string? DynamicRef { get; } + public System.Collections.Generic.IList? Enum { get; } + public System.Text.Json.Nodes.JsonNode? Example { get; } + public System.Collections.Generic.IList? Examples { get; } public decimal? ExclusiveMaximum { get; } public decimal? ExclusiveMinimum { get; } - public System.Collections.Generic.IDictionary Extensions { get; } - public Microsoft.OpenApi.Models.OpenApiExternalDocs ExternalDocs { get; } - public string Format { get; } - public string Id { get; } - public Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema Items { get; } + public System.Collections.Generic.IDictionary? Extensions { get; } + public Microsoft.OpenApi.Models.OpenApiExternalDocs? ExternalDocs { get; } + public string? Format { get; } + public string? Id { get; } + public Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema? Items { get; } public int? MaxItems { get; } public int? MaxLength { get; } public int? MaxProperties { get; } @@ -1382,23 +1381,23 @@ namespace Microsoft.OpenApi.Models.References public int? MinProperties { get; } public decimal? Minimum { get; } public decimal? MultipleOf { get; } - public Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema Not { get; } - public System.Collections.Generic.IList OneOf { get; } - public string Pattern { get; } - public System.Collections.Generic.IDictionary PatternProperties { get; } - public System.Collections.Generic.IDictionary Properties { get; } + public Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema? Not { get; } + public System.Collections.Generic.IList? OneOf { get; } + public string? Pattern { get; } + public System.Collections.Generic.IDictionary? PatternProperties { get; } + public System.Collections.Generic.IDictionary? Properties { get; } public bool ReadOnly { get; } - public System.Collections.Generic.ISet Required { get; } - public System.Uri Schema { get; } - public string Title { get; } + public System.Collections.Generic.ISet? Required { get; } + public System.Uri? Schema { get; } + public string? Title { get; } public Microsoft.OpenApi.Models.JsonSchemaType? Type { get; } public bool UnEvaluatedProperties { get; } public bool UnevaluatedProperties { get; } public bool? UniqueItems { get; } - public System.Collections.Generic.IDictionary UnrecognizedKeywords { get; } - public System.Collections.Generic.IDictionary Vocabulary { get; } + public System.Collections.Generic.IDictionary? UnrecognizedKeywords { get; } + public System.Collections.Generic.IDictionary? Vocabulary { get; } public bool WriteOnly { get; } - public Microsoft.OpenApi.Models.OpenApiXml Xml { get; } + public Microsoft.OpenApi.Models.OpenApiXml? Xml { get; } public override Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema CopyReferenceAsTargetElementWithOverrides(Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema source) { } public Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema CreateShallowCopy() { } public override void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -1407,27 +1406,27 @@ namespace Microsoft.OpenApi.Models.References } public class OpenApiSecuritySchemeReference : Microsoft.OpenApi.Models.References.BaseOpenApiReferenceHolder, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiSecurityScheme { - public OpenApiSecuritySchemeReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument hostDocument = null, string externalResource = null) { } - public string BearerFormat { get; } - public string Description { get; set; } - public System.Collections.Generic.IDictionary Extensions { get; } - public Microsoft.OpenApi.Models.OpenApiOAuthFlows Flows { get; } + public OpenApiSecuritySchemeReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument? hostDocument = null, string? externalResource = null) { } + public string? BearerFormat { get; } + public string? Description { get; set; } + public System.Collections.Generic.IDictionary? Extensions { get; } + public Microsoft.OpenApi.Models.OpenApiOAuthFlows? Flows { get; } public Microsoft.OpenApi.Models.ParameterLocation? In { get; } - public string Name { get; } - public System.Uri OpenIdConnectUrl { get; } - public string Scheme { get; } + public string? Name { get; } + public System.Uri? OpenIdConnectUrl { get; } + public string? Scheme { get; } public Microsoft.OpenApi.Models.SecuritySchemeType? Type { get; } public override Microsoft.OpenApi.Models.Interfaces.IOpenApiSecurityScheme CopyReferenceAsTargetElementWithOverrides(Microsoft.OpenApi.Models.Interfaces.IOpenApiSecurityScheme source) { } public Microsoft.OpenApi.Models.Interfaces.IOpenApiSecurityScheme CreateShallowCopy() { } } public class OpenApiTagReference : Microsoft.OpenApi.Models.References.BaseOpenApiReferenceHolder, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiReadOnlyDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiTag { - public OpenApiTagReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument hostDocument = null, string externalResource = null) { } - public string Description { get; } - public System.Collections.Generic.IDictionary Extensions { get; } - public Microsoft.OpenApi.Models.OpenApiExternalDocs ExternalDocs { get; } - public string Name { get; } - public override Microsoft.OpenApi.Models.Interfaces.IOpenApiTag Target { get; } + public OpenApiTagReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument? hostDocument = null, string? externalResource = null) { } + public string? Description { get; } + public System.Collections.Generic.IDictionary? Extensions { get; } + public Microsoft.OpenApi.Models.OpenApiExternalDocs? ExternalDocs { get; } + public string? Name { get; } + public override Microsoft.OpenApi.Models.Interfaces.IOpenApiTag? Target { get; } public override Microsoft.OpenApi.Models.Interfaces.IOpenApiTag CopyReferenceAsTargetElementWithOverrides(Microsoft.OpenApi.Models.Interfaces.IOpenApiTag source) { } public Microsoft.OpenApi.Models.Interfaces.IOpenApiTag CreateShallowCopy() { } } @@ -1440,7 +1439,7 @@ namespace Microsoft.OpenApi.Reader public System.Collections.Generic.IList Errors { get; set; } public Microsoft.OpenApi.OpenApiSpecVersion SpecificationVersion { get; set; } public System.Collections.Generic.IList Warnings { get; set; } - public void AppendDiagnostic(Microsoft.OpenApi.Reader.OpenApiDiagnostic diagnosticToAdd, string fileNameToAdd = null) { } + public void AppendDiagnostic(Microsoft.OpenApi.Reader.OpenApiDiagnostic diagnosticToAdd, string? fileNameToAdd = null) { } } public class OpenApiJsonReader : Microsoft.OpenApi.Interfaces.IOpenApiReader { @@ -1448,33 +1447,33 @@ namespace Microsoft.OpenApi.Reader public Microsoft.OpenApi.Reader.ReadResult Read(System.IO.MemoryStream input, Microsoft.OpenApi.Reader.OpenApiReaderSettings settings) { } public Microsoft.OpenApi.Reader.ReadResult Read(System.Text.Json.Nodes.JsonNode jsonNode, Microsoft.OpenApi.Reader.OpenApiReaderSettings settings) { } public System.Threading.Tasks.Task ReadAsync(System.IO.Stream input, Microsoft.OpenApi.Reader.OpenApiReaderSettings settings, System.Threading.CancellationToken cancellationToken = default) { } - public T ReadFragment(System.IO.MemoryStream input, Microsoft.OpenApi.OpenApiSpecVersion version, Microsoft.OpenApi.Models.OpenApiDocument openApiDocument, out Microsoft.OpenApi.Reader.OpenApiDiagnostic diagnostic, Microsoft.OpenApi.Reader.OpenApiReaderSettings settings = null) + public T? ReadFragment(System.IO.MemoryStream input, Microsoft.OpenApi.OpenApiSpecVersion version, Microsoft.OpenApi.Models.OpenApiDocument openApiDocument, out Microsoft.OpenApi.Reader.OpenApiDiagnostic diagnostic, Microsoft.OpenApi.Reader.OpenApiReaderSettings? settings = null) where T : Microsoft.OpenApi.Interfaces.IOpenApiElement { } - public T ReadFragment(System.Text.Json.Nodes.JsonNode input, Microsoft.OpenApi.OpenApiSpecVersion version, Microsoft.OpenApi.Models.OpenApiDocument openApiDocument, out Microsoft.OpenApi.Reader.OpenApiDiagnostic diagnostic, Microsoft.OpenApi.Reader.OpenApiReaderSettings settings = null) + public T? ReadFragment(System.Text.Json.Nodes.JsonNode input, Microsoft.OpenApi.OpenApiSpecVersion version, Microsoft.OpenApi.Models.OpenApiDocument openApiDocument, out Microsoft.OpenApi.Reader.OpenApiDiagnostic diagnostic, Microsoft.OpenApi.Reader.OpenApiReaderSettings? settings = null) where T : Microsoft.OpenApi.Interfaces.IOpenApiElement { } } public static class OpenApiModelFactory { - public static Microsoft.OpenApi.Reader.ReadResult Load(System.IO.MemoryStream stream, string format = null, Microsoft.OpenApi.Reader.OpenApiReaderSettings settings = null) { } - public static T Load(System.IO.MemoryStream input, Microsoft.OpenApi.OpenApiSpecVersion version, string format, Microsoft.OpenApi.Models.OpenApiDocument openApiDocument, out Microsoft.OpenApi.Reader.OpenApiDiagnostic diagnostic, Microsoft.OpenApi.Reader.OpenApiReaderSettings settings = null) + public static Microsoft.OpenApi.Reader.ReadResult Load(System.IO.MemoryStream stream, string? format = null, Microsoft.OpenApi.Reader.OpenApiReaderSettings? settings = null) { } + public static T? Load(System.IO.MemoryStream input, Microsoft.OpenApi.OpenApiSpecVersion version, string? format, Microsoft.OpenApi.Models.OpenApiDocument openApiDocument, out Microsoft.OpenApi.Reader.OpenApiDiagnostic diagnostic, Microsoft.OpenApi.Reader.OpenApiReaderSettings? settings = null) where T : Microsoft.OpenApi.Interfaces.IOpenApiElement { } - public static System.Threading.Tasks.Task LoadAsync(string url, Microsoft.OpenApi.Reader.OpenApiReaderSettings settings = null, System.Threading.CancellationToken token = default) { } - public static System.Threading.Tasks.Task LoadAsync(System.IO.Stream input, string format = null, Microsoft.OpenApi.Reader.OpenApiReaderSettings settings = null, System.Threading.CancellationToken cancellationToken = default) { } - public static System.Threading.Tasks.Task LoadAsync(string url, Microsoft.OpenApi.OpenApiSpecVersion version, Microsoft.OpenApi.Models.OpenApiDocument openApiDocument, Microsoft.OpenApi.Reader.OpenApiReaderSettings settings = null, System.Threading.CancellationToken token = default) + public static System.Threading.Tasks.Task LoadAsync(string url, Microsoft.OpenApi.Reader.OpenApiReaderSettings? settings = null, System.Threading.CancellationToken token = default) { } + public static System.Threading.Tasks.Task LoadAsync(System.IO.Stream input, string? format = null, Microsoft.OpenApi.Reader.OpenApiReaderSettings? settings = null, System.Threading.CancellationToken cancellationToken = default) { } + public static System.Threading.Tasks.Task LoadAsync(string url, Microsoft.OpenApi.OpenApiSpecVersion version, Microsoft.OpenApi.Models.OpenApiDocument openApiDocument, Microsoft.OpenApi.Reader.OpenApiReaderSettings? settings = null, System.Threading.CancellationToken token = default) where T : Microsoft.OpenApi.Interfaces.IOpenApiElement { } - public static System.Threading.Tasks.Task LoadAsync(System.IO.Stream input, Microsoft.OpenApi.OpenApiSpecVersion version, Microsoft.OpenApi.Models.OpenApiDocument openApiDocument, string format = null, Microsoft.OpenApi.Reader.OpenApiReaderSettings settings = null, System.Threading.CancellationToken token = default) + public static System.Threading.Tasks.Task LoadAsync(System.IO.Stream input, Microsoft.OpenApi.OpenApiSpecVersion version, Microsoft.OpenApi.Models.OpenApiDocument openApiDocument, string? format = null, Microsoft.OpenApi.Reader.OpenApiReaderSettings? settings = null, System.Threading.CancellationToken token = default) where T : Microsoft.OpenApi.Interfaces.IOpenApiElement { } - public static Microsoft.OpenApi.Reader.ReadResult Parse(string input, string format = null, Microsoft.OpenApi.Reader.OpenApiReaderSettings settings = null) { } - public static T Parse(string input, Microsoft.OpenApi.OpenApiSpecVersion version, Microsoft.OpenApi.Models.OpenApiDocument openApiDocument, out Microsoft.OpenApi.Reader.OpenApiDiagnostic diagnostic, string format = null, Microsoft.OpenApi.Reader.OpenApiReaderSettings settings = null) + public static Microsoft.OpenApi.Reader.ReadResult Parse(string input, string? format = null, Microsoft.OpenApi.Reader.OpenApiReaderSettings? settings = null) { } + public static T? Parse(string input, Microsoft.OpenApi.OpenApiSpecVersion version, Microsoft.OpenApi.Models.OpenApiDocument openApiDocument, out Microsoft.OpenApi.Reader.OpenApiDiagnostic diagnostic, string? format = null, Microsoft.OpenApi.Reader.OpenApiReaderSettings? settings = null) where T : Microsoft.OpenApi.Interfaces.IOpenApiElement { } } public class OpenApiReaderSettings { public OpenApiReaderSettings() { } - public System.Uri BaseUrl { get; set; } - public Microsoft.OpenApi.Interfaces.IStreamLoader CustomExternalLoader { get; set; } - public System.Collections.Generic.List DefaultContentType { get; set; } - public System.Collections.Generic.Dictionary> ExtensionParsers { get; set; } + public System.Uri? BaseUrl { get; set; } + public Microsoft.OpenApi.Interfaces.IStreamLoader? CustomExternalLoader { get; set; } + public System.Collections.Generic.List? DefaultContentType { get; set; } + public System.Collections.Generic.Dictionary>? ExtensionParsers { get; set; } public System.Net.Http.HttpClient HttpClient { init; } public bool LeaveStreamOpen { get; set; } public bool LoadExternalRefs { get; set; } @@ -1493,34 +1492,34 @@ namespace Microsoft.OpenApi.Reader public class ParsingContext { public ParsingContext(Microsoft.OpenApi.Reader.OpenApiDiagnostic diagnostic) { } - public System.Uri BaseUrl { get; set; } - public System.Collections.Generic.List DefaultContentType { get; set; } + public System.Uri? BaseUrl { get; set; } + public System.Collections.Generic.List? DefaultContentType { get; set; } public Microsoft.OpenApi.Reader.OpenApiDiagnostic Diagnostic { get; } - public System.Collections.Generic.Dictionary> ExtensionParsers { get; set; } + public System.Collections.Generic.Dictionary>? ExtensionParsers { get; set; } public void EndObject() { } - public T GetFromTempStorage(string key, object scope = null) { } + public T? GetFromTempStorage(string key, object? scope = null) { } public string GetLocation() { } public Microsoft.OpenApi.Models.OpenApiDocument Parse(System.Text.Json.Nodes.JsonNode jsonNode) { } - public T ParseFragment(System.Text.Json.Nodes.JsonNode jsonNode, Microsoft.OpenApi.OpenApiSpecVersion version, Microsoft.OpenApi.Models.OpenApiDocument openApiDocument) + public T? ParseFragment(System.Text.Json.Nodes.JsonNode jsonNode, Microsoft.OpenApi.OpenApiSpecVersion version, Microsoft.OpenApi.Models.OpenApiDocument openApiDocument) where T : Microsoft.OpenApi.Interfaces.IOpenApiElement { } public void PopLoop(string loopid) { } public bool PushLoop(string loopId, string key) { } - public void SetTempStorage(string key, object value, object scope = null) { } + public void SetTempStorage(string key, object? value, object? scope = null) { } public void StartObject(string objectName) { } } public class ReadResult { public ReadResult() { } - public Microsoft.OpenApi.Reader.OpenApiDiagnostic Diagnostic { get; set; } - public Microsoft.OpenApi.Models.OpenApiDocument Document { get; set; } - public void Deconstruct(out Microsoft.OpenApi.Models.OpenApiDocument document, out Microsoft.OpenApi.Reader.OpenApiDiagnostic diagnostic) { } + public Microsoft.OpenApi.Reader.OpenApiDiagnostic? Diagnostic { get; set; } + public Microsoft.OpenApi.Models.OpenApiDocument? Document { get; set; } + public void Deconstruct(out Microsoft.OpenApi.Models.OpenApiDocument? document, out Microsoft.OpenApi.Reader.OpenApiDiagnostic? diagnostic) { } } } namespace Microsoft.OpenApi.Reader.ParseNodes { public static class JsonPointerExtensions { - public static System.Text.Json.Nodes.JsonNode Find(this Microsoft.OpenApi.JsonPointer currentPointer, System.Text.Json.Nodes.JsonNode baseJsonNode) { } + public static System.Text.Json.Nodes.JsonNode? Find(this Microsoft.OpenApi.JsonPointer currentPointer, System.Text.Json.Nodes.JsonNode baseJsonNode) { } } } namespace Microsoft.OpenApi.Reader.Services @@ -1536,17 +1535,17 @@ namespace Microsoft.OpenApi.Services public class CurrentKeys { public CurrentKeys() { } - public string Callback { get; set; } - public string Content { get; set; } - public string Encoding { get; } - public string Example { get; } - public string Extension { get; } - public string Header { get; } - public string Link { get; set; } - public System.Net.Http.HttpMethod Operation { get; set; } - public string Path { get; set; } - public string Response { get; set; } - public string ServerVariable { get; } + public string? Callback { get; set; } + public string? Content { get; set; } + public string? Encoding { get; } + public string? Example { get; } + public string? Extension { get; } + public string? Header { get; } + public string? Link { get; set; } + public System.Net.Http.HttpMethod? Operation { get; set; } + public string? Path { get; set; } + public string? Response { get; set; } + public string? ServerVariable { get; } } public enum MermaidNodeShape { @@ -1565,11 +1564,11 @@ namespace Microsoft.OpenApi.Services { public static Microsoft.OpenApi.Models.OpenApiDocument CreateFilteredDocument(Microsoft.OpenApi.Models.OpenApiDocument source, System.Func predicate) { } public static Microsoft.OpenApi.Services.OpenApiUrlTreeNode CreateOpenApiUrlTreeNode(System.Collections.Generic.Dictionary sources) { } - public static System.Func CreatePredicate(string operationIds = null, string tags = null, System.Collections.Generic.Dictionary> requestUrls = null, Microsoft.OpenApi.Models.OpenApiDocument source = null) { } + public static System.Func CreatePredicate(string? operationIds = null, string? tags = null, System.Collections.Generic.Dictionary>? requestUrls = null, Microsoft.OpenApi.Models.OpenApiDocument? source = null) { } } public class OpenApiReferenceError : Microsoft.OpenApi.Models.OpenApiError { - public readonly Microsoft.OpenApi.Models.OpenApiReference Reference; + public readonly Microsoft.OpenApi.Models.OpenApiReference? Reference; public OpenApiReferenceError(Microsoft.OpenApi.Exceptions.OpenApiException exception) { } public OpenApiReferenceError(Microsoft.OpenApi.Models.OpenApiReference reference, string message) { } } @@ -1647,18 +1646,18 @@ namespace Microsoft.OpenApi.Services public class OpenApiWalker { public OpenApiWalker(Microsoft.OpenApi.Services.OpenApiVisitorBase visitor) { } - public void Walk(Microsoft.OpenApi.Models.OpenApiDocument doc) { } + public void Walk(Microsoft.OpenApi.Models.OpenApiDocument? doc) { } } public class OpenApiWorkspace { public OpenApiWorkspace() { } public OpenApiWorkspace(Microsoft.OpenApi.Services.OpenApiWorkspace workspace) { } public OpenApiWorkspace(System.Uri baseUrl) { } - public System.Uri BaseUrl { get; } - public void AddDocumentId(string key, System.Uri value) { } + public System.Uri? BaseUrl { get; } + public void AddDocumentId(string? key, System.Uri? value) { } public int ComponentsCount() { } public bool Contains(string location) { } - public System.Uri GetDocumentId(string key) { } + public System.Uri? GetDocumentId(string? key) { } public bool RegisterComponentForDocument(Microsoft.OpenApi.Models.OpenApiDocument openApiDocument, T componentToRegister, string id) { } public void RegisterComponents(Microsoft.OpenApi.Models.OpenApiDocument document) { } public T? ResolveReference(string location) { } @@ -1673,16 +1672,15 @@ namespace Microsoft.OpenApi.Services public class SearchResult { public SearchResult() { } - public Microsoft.OpenApi.Services.CurrentKeys CurrentKeys { get; set; } - public Microsoft.OpenApi.Models.OpenApiOperation Operation { get; set; } - public System.Collections.Generic.IList Parameters { get; set; } + public Microsoft.OpenApi.Services.CurrentKeys? CurrentKeys { get; set; } + public Microsoft.OpenApi.Models.OpenApiOperation? Operation { get; set; } + public System.Collections.Generic.IList? Parameters { get; set; } } } namespace Microsoft.OpenApi.Validations { public interface IValidationContext { - Microsoft.OpenApi.Models.OpenApiDocument HostDocument { get; } string PathString { get; } void AddError(Microsoft.OpenApi.Validations.OpenApiValidatorError error); void AddWarning(Microsoft.OpenApi.Validations.OpenApiValidatorWarning warning); @@ -1691,9 +1689,8 @@ namespace Microsoft.OpenApi.Validations } public class OpenApiValidator : Microsoft.OpenApi.Services.OpenApiVisitorBase, Microsoft.OpenApi.Validations.IValidationContext { - public OpenApiValidator(Microsoft.OpenApi.Validations.ValidationRuleSet ruleSet, Microsoft.OpenApi.Models.OpenApiDocument hostDocument = null) { } + public OpenApiValidator(Microsoft.OpenApi.Validations.ValidationRuleSet ruleSet) { } public System.Collections.Generic.IEnumerable Errors { get; } - public Microsoft.OpenApi.Models.OpenApiDocument HostDocument { get; set; } public System.Collections.Generic.IEnumerable Warnings { get; } public void AddError(Microsoft.OpenApi.Validations.OpenApiValidatorError error) { } public void AddWarning(Microsoft.OpenApi.Validations.OpenApiValidatorWarning warning) { } @@ -1772,7 +1769,7 @@ namespace Microsoft.OpenApi.Validations public bool Remove(System.Type key) { } public void Remove(string ruleName) { } public bool Remove(System.Type key, Microsoft.OpenApi.Validations.ValidationRule rule) { } - public bool TryGetValue(System.Type key, out System.Collections.Generic.IList rules) { } + public bool TryGetValue(System.Type key, out System.Collections.Generic.IList? rules) { } public bool Update(System.Type key, Microsoft.OpenApi.Validations.ValidationRule newRule, Microsoft.OpenApi.Validations.ValidationRule oldRule) { } public static void AddValidationRules(Microsoft.OpenApi.Validations.ValidationRuleSet ruleSet, System.Collections.Generic.IDictionary> rules) { } public static Microsoft.OpenApi.Validations.ValidationRuleSet GetDefaultRuleSet() { } @@ -1865,8 +1862,8 @@ namespace Microsoft.OpenApi.Validations.Rules public static class OpenApiSchemaRules { public static Microsoft.OpenApi.Validations.ValidationRule ValidateSchemaDiscriminator { get; } - public static bool TraverseSchemaElements(string discriminatorName, System.Collections.Generic.IList childSchema) { } - public static bool ValidateChildSchemaAgainstDiscriminator(Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema schema, string discriminatorName) { } + public static bool TraverseSchemaElements(string discriminatorName, System.Collections.Generic.IList? childSchema) { } + public static bool ValidateChildSchemaAgainstDiscriminator(Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema schema, string? discriminatorName) { } } [Microsoft.OpenApi.Validations.Rules.OpenApiRule] public static class OpenApiServerRules @@ -1906,7 +1903,7 @@ namespace Microsoft.OpenApi.Writers { public OpenApiJsonWriter(System.IO.TextWriter textWriter) { } public OpenApiJsonWriter(System.IO.TextWriter textWriter, Microsoft.OpenApi.Writers.OpenApiJsonWriterSettings settings) { } - public OpenApiJsonWriter(System.IO.TextWriter textWriter, Microsoft.OpenApi.Writers.OpenApiWriterSettings settings, bool terseOutput = false) { } + public OpenApiJsonWriter(System.IO.TextWriter textWriter, Microsoft.OpenApi.Writers.OpenApiWriterSettings? settings, bool terseOutput = false) { } protected override int BaseIndentation { get; } public override void WriteEndArray() { } public override void WriteEndObject() { } @@ -1926,19 +1923,19 @@ namespace Microsoft.OpenApi.Writers } public static class OpenApiWriterAnyExtensions { - public static void WriteAny(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, System.Text.Json.Nodes.JsonNode node) { } - public static void WriteExtensions(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, System.Collections.Generic.IDictionary extensions, Microsoft.OpenApi.OpenApiSpecVersion specVersion) { } + public static void WriteAny(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, System.Text.Json.Nodes.JsonNode? node) { } + public static void WriteExtensions(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, System.Collections.Generic.IDictionary? extensions, Microsoft.OpenApi.OpenApiSpecVersion specVersion) { } } public abstract class OpenApiWriterBase : Microsoft.OpenApi.Writers.IOpenApiWriter { protected const string IndentationString = " "; protected readonly System.Collections.Generic.Stack Scopes; protected OpenApiWriterBase(System.IO.TextWriter textWriter) { } - protected OpenApiWriterBase(System.IO.TextWriter textWriter, Microsoft.OpenApi.Writers.OpenApiWriterSettings settings) { } + protected OpenApiWriterBase(System.IO.TextWriter textWriter, Microsoft.OpenApi.Writers.OpenApiWriterSettings? settings) { } protected abstract int BaseIndentation { get; } public Microsoft.OpenApi.Writers.OpenApiWriterSettings Settings { get; set; } protected System.IO.TextWriter Writer { get; } - protected Microsoft.OpenApi.Writers.Scope CurrentScope() { } + protected Microsoft.OpenApi.Writers.Scope? CurrentScope() { } public virtual void DecreaseIndentation() { } protected Microsoft.OpenApi.Writers.Scope EndScope(Microsoft.OpenApi.Writers.ScopeType type) { } public System.Threading.Tasks.Task FlushAsync(System.Threading.CancellationToken cancellationToken = default) { } @@ -1957,7 +1954,6 @@ namespace Microsoft.OpenApi.Writers public abstract void WriteRaw(string value); public abstract void WriteStartArray(); public abstract void WriteStartObject(); - public void WriteV2Examples(Microsoft.OpenApi.Writers.IOpenApiWriter writer, Microsoft.OpenApi.Models.OpenApiExample example, Microsoft.OpenApi.OpenApiSpecVersion version) { } public virtual void WriteValue(System.DateTime value) { } public virtual void WriteValue(System.DateTimeOffset value) { } public virtual void WriteValue(bool value) { } @@ -1966,24 +1962,25 @@ namespace Microsoft.OpenApi.Writers public virtual void WriteValue(float value) { } public virtual void WriteValue(int value) { } public virtual void WriteValue(long value) { } - public virtual void WriteValue(object value) { } + public virtual void WriteValue(object? value) { } public abstract void WriteValue(string value); protected abstract void WriteValueSeparator(); + public static void WriteV2Examples(Microsoft.OpenApi.Writers.IOpenApiWriter writer, Microsoft.OpenApi.Models.OpenApiExample example, Microsoft.OpenApi.OpenApiSpecVersion version) { } } public static class OpenApiWriterExtensions { - public static void WriteOptionalCollection(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.IEnumerable elements, System.Action action) { } - public static void WriteOptionalCollection(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.IEnumerable elements, System.Action action) { } - public static void WriteOptionalMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.IDictionary> elements, System.Action> action) { } - public static void WriteOptionalMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.IDictionary elements, System.Action action) { } - public static void WriteOptionalMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.IDictionary elements, System.Action action) { } - public static void WriteOptionalMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.IDictionary elements, System.Action action) { } - public static void WriteOptionalMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.IDictionary elements, System.Action action) + public static void WriteOptionalCollection(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.IEnumerable? elements, System.Action action) { } + public static void WriteOptionalCollection(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.IEnumerable? elements, System.Action action) { } + public static void WriteOptionalMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.IDictionary>? elements, System.Action> action) { } + public static void WriteOptionalMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.IDictionary? elements, System.Action action) { } + public static void WriteOptionalMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.IDictionary? elements, System.Action action) { } + public static void WriteOptionalMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.IDictionary? elements, System.Action action) { } + public static void WriteOptionalMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.IDictionary? elements, System.Action action) where T : Microsoft.OpenApi.Interfaces.IOpenApiElement { } - public static void WriteOptionalMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.IDictionary elements, System.Action action) + public static void WriteOptionalMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.IDictionary? elements, System.Action action) where T : Microsoft.OpenApi.Interfaces.IOpenApiElement { } public static void WriteOptionalObject(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, T? value, System.Action action) { } - public static void WriteProperty(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, string value) { } + public static void WriteProperty(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, string? value) { } public static void WriteProperty(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, bool value, bool defaultValue = false) { } public static void WriteProperty(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, bool? value, bool defaultValue = false) { } public static void WriteProperty(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, T value) @@ -1992,11 +1989,11 @@ namespace Microsoft.OpenApi.Writers where T : struct { } public static void WriteRequiredCollection(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.IEnumerable elements, System.Action action) where T : Microsoft.OpenApi.Interfaces.IOpenApiElement { } - public static void WriteRequiredMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.IDictionary elements, System.Action action) { } - public static void WriteRequiredMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.IDictionary elements, System.Action action) + public static void WriteRequiredMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.IDictionary? elements, System.Action action) { } + public static void WriteRequiredMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.IDictionary? elements, System.Action action) where T : Microsoft.OpenApi.Interfaces.IOpenApiElement { } public static void WriteRequiredObject(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, T? value, System.Action action) { } - public static void WriteRequiredProperty(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, string value) { } + public static void WriteRequiredProperty(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, string? value) { } } public class OpenApiWriterSettings { @@ -2007,7 +2004,7 @@ namespace Microsoft.OpenApi.Writers public class OpenApiYamlWriter : Microsoft.OpenApi.Writers.OpenApiWriterBase { public OpenApiYamlWriter(System.IO.TextWriter textWriter) { } - public OpenApiYamlWriter(System.IO.TextWriter textWriter, Microsoft.OpenApi.Writers.OpenApiWriterSettings settings) { } + public OpenApiYamlWriter(System.IO.TextWriter textWriter, Microsoft.OpenApi.Writers.OpenApiWriterSettings? settings) { } protected override int BaseIndentation { get; } public bool UseLiteralStyle { get; set; } public override void WriteEndArray() { } diff --git a/test/Microsoft.OpenApi.Tests/Walkers/WalkerLocationTests.cs b/test/Microsoft.OpenApi.Tests/Walkers/WalkerLocationTests.cs index feee331af..6af474e22 100644 --- a/test/Microsoft.OpenApi.Tests/Walkers/WalkerLocationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Walkers/WalkerLocationTests.cs @@ -58,8 +58,7 @@ public void LocateTopLevelArrayItems() "#/servers/0", "#/servers/1", "#/paths", - "#/tags", - "#/tags/0" + "#/tags" }, locator.Locations); } From 22fca8df537f3a9fd32962c3f06d841dc4ac4963 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Fri, 14 Mar 2025 13:37:40 +0000 Subject: [PATCH 023/984] chore(main): release 2.0.0-preview.13 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 16 ++++++++++++++++ Directory.Build.props | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 1db2241f1..112d044e7 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "2.0.0-preview.12" + ".": "2.0.0-preview.13" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f001984b..0a4599468 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,21 @@ # Changelog +## [2.0.0-preview.13](https://github.com/microsoft/OpenAPI.NET/compare/v2.0.0-preview.12...v2.0.0-preview.13) (2025-03-14) + + +### Features + +* adds OpenApiDocument.SerializeAs() so simplify serialization scenarios ([371a574](https://github.com/microsoft/OpenAPI.NET/commit/371a57405b013bdc257a51cc831f7487d1749823)) +* enable null reference type support ([#2146](https://github.com/microsoft/OpenAPI.NET/issues/2146)) ([96574ec](https://github.com/microsoft/OpenAPI.NET/commit/96574ecc46dca647a708b6673c7e5309824eda2f)) +* enables references as components ([eeffba9](https://github.com/microsoft/OpenAPI.NET/commit/eeffba9d50a53a3be1630d01edd8d0b57a966dee)) +* use http method object instead of enum ([8baff28](https://github.com/microsoft/OpenAPI.NET/commit/8baff287aa9450ad3bd467816de321e30157bcb3)) + + +### Bug Fixes + +* a bug where references would not serialize summary or descriptions in 3.1 ([ca7ccdd](https://github.com/microsoft/OpenAPI.NET/commit/ca7ccdd933b57c2775d0295e22e541c2904b5fb7)) +* handling for reference IDs with http prefix ([3385a0e](https://github.com/microsoft/OpenAPI.NET/commit/3385a0e0088c44fb926affcb20f166a02391427c)) + ## [2.0.0-preview.12](https://github.com/microsoft/OpenAPI.NET/compare/v2.0.0-preview.11...v2.0.0-preview.12) (2025-03-07) diff --git a/Directory.Build.props b/Directory.Build.props index 5e4ab85d0..1254e69f5 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -12,7 +12,7 @@ https://github.com/Microsoft/OpenAPI.NET © Microsoft Corporation. All rights reserved. OpenAPI .NET - 2.0.0-preview.12 + 2.0.0-preview.13 From d75666ded017bfa175662a7753a31b0edc047dc8 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Mon, 17 Mar 2025 15:32:03 +0300 Subject: [PATCH 024/984] chore: reference the new namespace in tests --- .../OpenApiReaderSettingsExtensions.cs | 5 ++--- .../OpenApiReaderSettingsExtensionsTests.cs | 3 ++- test/Microsoft.OpenApi.Readers.Tests/TestHelper.cs | 3 ++- .../V2Tests/OpenApiSecuritySchemeTests.cs | 1 + .../V31Tests/OpenApiInfoTests.cs | 3 ++- .../V31Tests/OpenApiLicenseTests.cs | 3 ++- .../V3Tests/OpenApiSchemaTests.cs | 1 + 7 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/Microsoft.OpenApi.YamlReader/OpenApiReaderSettingsExtensions.cs b/src/Microsoft.OpenApi.YamlReader/OpenApiReaderSettingsExtensions.cs index a60e051a8..6d43c87aa 100644 --- a/src/Microsoft.OpenApi.YamlReader/OpenApiReaderSettingsExtensions.cs +++ b/src/Microsoft.OpenApi.YamlReader/OpenApiReaderSettingsExtensions.cs @@ -1,6 +1,5 @@ -using Microsoft.OpenApi.Interfaces; -using Microsoft.OpenApi.Models; -using Microsoft.OpenApi.Readers; +using Microsoft.OpenApi.Models; +using Microsoft.OpenApi.YamlReader; namespace Microsoft.OpenApi.Reader; diff --git a/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderSettingsExtensionsTests.cs b/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderSettingsExtensionsTests.cs index 2d69bcf73..8e7f2854e 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderSettingsExtensionsTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderSettingsExtensionsTests.cs @@ -1,6 +1,7 @@ -using System; +using System; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Reader; +using Microsoft.OpenApi.YamlReader; using Xunit; namespace Microsoft.OpenApi.Readers.Tests; diff --git a/test/Microsoft.OpenApi.Readers.Tests/TestHelper.cs b/test/Microsoft.OpenApi.Readers.Tests/TestHelper.cs index f8b222c36..c7911f3e4 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/TestHelper.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/TestHelper.cs @@ -5,6 +5,7 @@ using System.Linq; using Microsoft.OpenApi.Reader; using Microsoft.OpenApi.Reader.ParseNodes; +using Microsoft.OpenApi.YamlReader; using SharpYaml.Serialization; namespace Microsoft.OpenApi.Readers.Tests @@ -15,7 +16,7 @@ public static MapNode CreateYamlMapNode(Stream stream) { var yamlStream = new YamlStream(); yamlStream.Load(new StreamReader(stream)); - var yamlNode = yamlStream.Documents.First().RootNode; + var yamlNode = yamlStream.Documents[0].RootNode; var context = new ParsingContext(new OpenApiDiagnostic()); var asJsonNode = yamlNode.ToJsonNode(); diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSecuritySchemeTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSecuritySchemeTests.cs index 562753a19..bdac6ac26 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSecuritySchemeTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSecuritySchemeTests.cs @@ -8,6 +8,7 @@ using Microsoft.OpenApi.Reader; using Microsoft.OpenApi.Reader.ParseNodes; using Microsoft.OpenApi.Reader.V2; +using Microsoft.OpenApi.YamlReader; using SharpYaml.Serialization; using Xunit; diff --git a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiInfoTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiInfoTests.cs index 409dd4c79..6d183970d 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiInfoTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiInfoTests.cs @@ -5,6 +5,7 @@ using Microsoft.OpenApi.Reader; using Microsoft.OpenApi.Reader.ParseNodes; using Microsoft.OpenApi.Reader.V31; +using Microsoft.OpenApi.YamlReader; using SharpYaml.Serialization; using Xunit; @@ -20,7 +21,7 @@ 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 yamlNode = yamlStream.Documents[0].RootNode; var diagnostic = new OpenApiDiagnostic(); var context = new ParsingContext(diagnostic); diff --git a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiLicenseTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiLicenseTests.cs index 05bc9281b..46f8931dd 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiLicenseTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiLicenseTests.cs @@ -7,6 +7,7 @@ using Microsoft.OpenApi.Reader; using Microsoft.OpenApi.Reader.ParseNodes; using Microsoft.OpenApi.Reader.V31; +using Microsoft.OpenApi.YamlReader; using SharpYaml.Serialization; using Xunit; @@ -23,7 +24,7 @@ public void ParseLicenseWithSpdxIdentifierShouldSucceed() using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "licenseWithSpdxIdentifier.yaml")); var yamlStream = new YamlStream(); yamlStream.Load(new StreamReader(stream)); - var yamlNode = yamlStream.Documents.First().RootNode; + var yamlNode = yamlStream.Documents[0].RootNode; var diagnostic = new OpenApiDiagnostic(); var context = new ParsingContext(diagnostic); diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs index 9205541cd..cdc80e603 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs @@ -17,6 +17,7 @@ using Microsoft.OpenApi.Models.References; using System.Threading.Tasks; using System.Net.Http; +using Microsoft.OpenApi.YamlReader; namespace Microsoft.OpenApi.Readers.Tests.V3Tests { From 72daa544f2bfe8d51ed69d7ba82d31cbc36580f2 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Mon, 17 Mar 2025 15:33:02 +0300 Subject: [PATCH 025/984] fix: exclude hidi from release due to package source mapping conflict --- .azure-pipelines/ci-build.yml | 6 +++--- Microsoft.OpenApi.sln | 14 -------------- .../Microsoft.OpenApi.Tests.csproj | 3 ++- 3 files changed, 5 insertions(+), 18 deletions(-) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index c36d60872..6fb17edea 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -145,9 +145,9 @@ extends: displayName: 'pack Readers' # Pack hidi - - pwsh: dotnet pack $(Build.SourcesDirectory)/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj -o $(Build.ArtifactStagingDirectory) --configuration $(BuildConfiguration) --no-build --include-symbols --include-source /p:SymbolPackageFormat=snupkg - displayName: 'pack Hidi' - + # - pwsh: dotnet pack $(Build.SourcesDirectory)/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj -o $(Build.ArtifactStagingDirectory) --configuration $(BuildConfiguration) --no-build --include-symbols --include-source /p:SymbolPackageFormat=snupkg + # displayName: 'pack Hidi' + - task: EsrpCodeSigning@5 displayName: 'ESRP CodeSigning Nuget Packages' inputs: diff --git a/Microsoft.OpenApi.sln b/Microsoft.OpenApi.sln index aa64dc5be..afc862a44 100644 --- a/Microsoft.OpenApi.sln +++ b/Microsoft.OpenApi.sln @@ -24,10 +24,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{E546B92F-20A EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{6357D7FD-2DE4-4900-ADB9-ABC37052040A}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.OpenApi.Hidi", "src\Microsoft.OpenApi.Hidi\Microsoft.OpenApi.Hidi.csproj", "{254841B5-7DAC-4D1D-A9C5-44FE5CE467BE}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.OpenApi.Hidi.Tests", "test\Microsoft.OpenApi.Hidi.Tests\Microsoft.OpenApi.Hidi.Tests.csproj", "{D8F799DD-04AC-4A13-B344-45A5B944450A}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.OpenApi.Trimming.Tests", "test\Microsoft.OpenApi.Trimming.Tests\Microsoft.OpenApi.Trimming.Tests.csproj", "{1D2E0C6E-B103-4CB6-912E-D56FA1501296}" EndProject Global @@ -56,14 +52,6 @@ Global {1ED3C2C1-E1E7-4925-B4E6-2D969C3F5237}.Debug|Any CPU.Build.0 = Debug|Any CPU {1ED3C2C1-E1E7-4925-B4E6-2D969C3F5237}.Release|Any CPU.ActiveCfg = Release|Any CPU {1ED3C2C1-E1E7-4925-B4E6-2D969C3F5237}.Release|Any CPU.Build.0 = Release|Any CPU - {254841B5-7DAC-4D1D-A9C5-44FE5CE467BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {254841B5-7DAC-4D1D-A9C5-44FE5CE467BE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {254841B5-7DAC-4D1D-A9C5-44FE5CE467BE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {254841B5-7DAC-4D1D-A9C5-44FE5CE467BE}.Release|Any CPU.Build.0 = Release|Any CPU - {D8F799DD-04AC-4A13-B344-45A5B944450A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D8F799DD-04AC-4A13-B344-45A5B944450A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D8F799DD-04AC-4A13-B344-45A5B944450A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D8F799DD-04AC-4A13-B344-45A5B944450A}.Release|Any CPU.Build.0 = Release|Any CPU {1D2E0C6E-B103-4CB6-912E-D56FA1501296}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1D2E0C6E-B103-4CB6-912E-D56FA1501296}.Debug|Any CPU.Build.0 = Debug|Any CPU {1D2E0C6E-B103-4CB6-912E-D56FA1501296}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -78,8 +66,6 @@ Global {79933258-0126-4382-8755-D50820ECC483} = {E546B92F-20A8-49C3-8323-4B25BB78F3E1} {AD83F991-DBF3-4251-8613-9CC54C826964} = {6357D7FD-2DE4-4900-ADB9-ABC37052040A} {1ED3C2C1-E1E7-4925-B4E6-2D969C3F5237} = {6357D7FD-2DE4-4900-ADB9-ABC37052040A} - {254841B5-7DAC-4D1D-A9C5-44FE5CE467BE} = {E546B92F-20A8-49C3-8323-4B25BB78F3E1} - {D8F799DD-04AC-4A13-B344-45A5B944450A} = {6357D7FD-2DE4-4900-ADB9-ABC37052040A} {1D2E0C6E-B103-4CB6-912E-D56FA1501296} = {6357D7FD-2DE4-4900-ADB9-ABC37052040A} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index e7bbe5e68..323ee97f7 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -14,6 +14,7 @@ + @@ -22,7 +23,7 @@ - + From fab2dd7f3300d5c58ac01e2c5e166153be603df6 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Mon, 17 Mar 2025 16:20:44 +0300 Subject: [PATCH 026/984] chore: exclude hidi publish step from build --- .azure-pipelines/ci-build.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index 6fb17edea..a5ad9cee3 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -183,14 +183,14 @@ extends: PendingAnalysisWaitTimeoutMinutes: '5' # publish hidi as an .exe - - task: DotNetCoreCLI@2 - displayName: publish Hidi as executable - inputs: - command: 'publish' - arguments: -c Release --runtime win-x64 /p:PublishSingleFile=true /p:PackAsTool=false --self-contained --output $(Build.ArtifactStagingDirectory)/Microsoft.OpenApi.Hidi - projects: 'src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj' - publishWebProjects: False - zipAfterPublish: false + # - task: DotNetCoreCLI@2 + # displayName: publish Hidi as executable + # inputs: + # command: 'publish' + # arguments: -c Release --runtime win-x64 /p:PublishSingleFile=true /p:PackAsTool=false --self-contained --output $(Build.ArtifactStagingDirectory)/Microsoft.OpenApi.Hidi + # projects: 'src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj' + # publishWebProjects: False + # zipAfterPublish: false - task: CopyFiles@2 displayName: Prepare staging folder for upload From 07e32d3d0078ff6e93bc81b0a69d552f76b2fb33 Mon Sep 17 00:00:00 2001 From: Romain Vergnory Date: Mon, 17 Mar 2025 17:51:43 +0100 Subject: [PATCH 027/984] fix: remove duplicate property --- src/Microsoft.OpenApi/Models/Interfaces/IOpenApiSchema.cs | 5 ----- .../Models/References/OpenApiSchemaReference.cs | 2 -- 2 files changed, 7 deletions(-) diff --git a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiSchema.cs b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiSchema.cs index bd551a786..954e6b094 100644 --- a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiSchema.cs +++ b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiSchema.cs @@ -63,11 +63,6 @@ public interface IOpenApiSchema : IOpenApiDescribedElement, IOpenApiReadOnlyExte /// public decimal? ExclusiveMinimum { get; } - /// - /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 - /// - public bool UnEvaluatedProperties { get; } - /// /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 /// Value MUST be a string in V2 and V3. diff --git a/src/Microsoft.OpenApi/Models/References/OpenApiSchemaReference.cs b/src/Microsoft.OpenApi/Models/References/OpenApiSchemaReference.cs index 2873065fd..e8ce0d907 100644 --- a/src/Microsoft.OpenApi/Models/References/OpenApiSchemaReference.cs +++ b/src/Microsoft.OpenApi/Models/References/OpenApiSchemaReference.cs @@ -64,8 +64,6 @@ public string? Description /// public decimal? ExclusiveMinimum { get => Target?.ExclusiveMinimum; } /// - public bool UnEvaluatedProperties { get => Target?.UnEvaluatedProperties ?? false; } - /// public JsonSchemaType? Type { get => Target?.Type; } /// public string? Const { get => Target?.Const; } From 21cffc032342c7fdf71753c6114aff48acfb69d3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Mar 2025 21:40:31 +0000 Subject: [PATCH 028/984] chore(deps): bump Microsoft.VisualStudio.Threading.Analyzers Bumps [Microsoft.VisualStudio.Threading.Analyzers](https://github.com/microsoft/vs-threading) from 17.13.2 to 17.13.61. - [Release notes](https://github.com/microsoft/vs-threading/releases) - [Commits](https://github.com/microsoft/vs-threading/commits) --- updated-dependencies: - dependency-name: Microsoft.VisualStudio.Threading.Analyzers dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 4 ++-- .../Microsoft.OpenApi.Readers.csproj | 4 ++-- src/Microsoft.OpenApi/Microsoft.OpenApi.csproj | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index 60437d3f1..f510d9876 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -1,4 +1,4 @@ - + Exe @@ -32,7 +32,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj index 8e55c6487..c2b154da9 100644 --- a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj +++ b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj @@ -1,4 +1,4 @@ - + netstandard2.0;net8.0; @@ -28,7 +28,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj index b3a511e88..ac13b8af2 100644 --- a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj +++ b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj @@ -1,4 +1,4 @@ - + netstandard2.0;net8.0 Latest @@ -49,7 +49,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all From 8c861063665686bd44476d6a82b0879da67ec4c3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Mar 2025 21:41:00 +0000 Subject: [PATCH 029/984] chore(deps): bump Verify.Xunit from 28.15.0 to 28.16.0 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 28.15.0 to 28.16.0. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/28.15.0...28.16.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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 36e360d6c..d2542da81 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -1,4 +1,4 @@ - + net8.0 false @@ -14,7 +14,7 @@ - + From 91ec5f2888e4ef08678d264d931c743791acfff9 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Tue, 18 Mar 2025 10:56:31 +0300 Subject: [PATCH 030/984] chore: update package description --- .../Microsoft.OpenApi.YamlReader.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi.YamlReader/Microsoft.OpenApi.YamlReader.csproj b/src/Microsoft.OpenApi.YamlReader/Microsoft.OpenApi.YamlReader.csproj index 8e55c6487..89f0f19cb 100644 --- a/src/Microsoft.OpenApi.YamlReader/Microsoft.OpenApi.YamlReader.csproj +++ b/src/Microsoft.OpenApi.YamlReader/Microsoft.OpenApi.YamlReader.csproj @@ -4,7 +4,7 @@ latest true - OpenAPI.NET Readers for JSON and YAML documents + OpenAPI.NET Reader for YAML documents true true true From 50bdc63c52ce03151c940d7464cf0aaac2210452 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Tue, 18 Mar 2025 08:19:31 +0000 Subject: [PATCH 031/984] chore(main): release 2.0.0-preview.14 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 7 +++++++ Directory.Build.props | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 112d044e7..18bc6068c 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "2.0.0-preview.13" + ".": "2.0.0-preview.14" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a4599468..c315bbe44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [2.0.0-preview.14](https://github.com/microsoft/OpenAPI.NET/compare/v2.0.0-preview.13...v2.0.0-preview.14) (2025-03-18) + + +### Bug Fixes + +* exclude hidi from release due to package source mapping conflict ([72daa54](https://github.com/microsoft/OpenAPI.NET/commit/72daa544f2bfe8d51ed69d7ba82d31cbc36580f2)) + ## [2.0.0-preview.13](https://github.com/microsoft/OpenAPI.NET/compare/v2.0.0-preview.12...v2.0.0-preview.13) (2025-03-14) diff --git a/Directory.Build.props b/Directory.Build.props index 1254e69f5..57b0bcda4 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -12,7 +12,7 @@ https://github.com/Microsoft/OpenAPI.NET © Microsoft Corporation. All rights reserved. OpenAPI .NET - 2.0.0-preview.13 + 2.0.0-preview.14 From c3afe4e8af2526e957940503a31079ed5f027c0a Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Tue, 18 Mar 2025 16:06:55 +0300 Subject: [PATCH 032/984] fix: revert change to exclude hidi in solution --- .azure-pipelines/ci-build.yml | 26 +++++++++---------- Microsoft.OpenApi.sln | 14 ++++++++++ src/Microsoft.OpenApi/Models/OpenApiSchema.cs | 2 +- .../Microsoft.OpenApi.Tests.csproj | 2 +- 4 files changed, 29 insertions(+), 15 deletions(-) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index a5ad9cee3..c916a3bc6 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -140,13 +140,13 @@ extends: - pwsh: dotnet pack $(Build.SourcesDirectory)/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj -o $(Build.ArtifactStagingDirectory) --configuration $(BuildConfiguration) --no-build --include-symbols --include-source /p:SymbolPackageFormat=snupkg displayName: 'pack OpenAPI' - # Pack readers + # Pack YamlReader - pwsh: dotnet pack $(Build.SourcesDirectory)/src/Microsoft.OpenApi.YamlReader/Microsoft.OpenApi.YamlReader.csproj -o $(Build.ArtifactStagingDirectory) --configuration $(BuildConfiguration) --no-build --include-symbols --include-source /p:SymbolPackageFormat=snupkg - displayName: 'pack Readers' + displayName: 'pack YamlReader' # Pack hidi - # - pwsh: dotnet pack $(Build.SourcesDirectory)/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj -o $(Build.ArtifactStagingDirectory) --configuration $(BuildConfiguration) --no-build --include-symbols --include-source /p:SymbolPackageFormat=snupkg - # displayName: 'pack Hidi' + - pwsh: dotnet pack $(Build.SourcesDirectory)/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj -o $(Build.ArtifactStagingDirectory) --configuration $(BuildConfiguration) --no-build --include-symbols --include-source /p:SymbolPackageFormat=snupkg + displayName: 'pack Hidi' - task: EsrpCodeSigning@5 displayName: 'ESRP CodeSigning Nuget Packages' @@ -183,14 +183,14 @@ extends: PendingAnalysisWaitTimeoutMinutes: '5' # publish hidi as an .exe - # - task: DotNetCoreCLI@2 - # displayName: publish Hidi as executable - # inputs: - # command: 'publish' - # arguments: -c Release --runtime win-x64 /p:PublishSingleFile=true /p:PackAsTool=false --self-contained --output $(Build.ArtifactStagingDirectory)/Microsoft.OpenApi.Hidi - # projects: 'src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj' - # publishWebProjects: False - # zipAfterPublish: false + - task: DotNetCoreCLI@2 + displayName: publish Hidi as executable + inputs: + command: 'publish' + arguments: -c Release --runtime win-x64 /p:PublishSingleFile=true /p:PackAsTool=false --self-contained --output $(Build.ArtifactStagingDirectory)/Microsoft.OpenApi.Hidi + projects: 'src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj' + publishWebProjects: False + zipAfterPublish: false - task: CopyFiles@2 displayName: Prepare staging folder for upload @@ -259,7 +259,7 @@ extends: nuGetFeedType: external publishFeedCredentials: 'OpenAPI Nuget Connection' - - deployment: deploy_readers + - deployment: deploy_yaml_reader templateContext: type: releaseJob isProduction: true diff --git a/Microsoft.OpenApi.sln b/Microsoft.OpenApi.sln index afc862a44..b1444995a 100644 --- a/Microsoft.OpenApi.sln +++ b/Microsoft.OpenApi.sln @@ -26,6 +26,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{6357D7FD-2 EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.OpenApi.Trimming.Tests", "test\Microsoft.OpenApi.Trimming.Tests\Microsoft.OpenApi.Trimming.Tests.csproj", "{1D2E0C6E-B103-4CB6-912E-D56FA1501296}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.OpenApi.Hidi", "src\Microsoft.OpenApi.Hidi\Microsoft.OpenApi.Hidi.csproj", "{538936B4-5E14-4EA3-9FD0-F43E2DD014FB}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.OpenApi.Hidi.Tests", "test\Microsoft.OpenApi.Hidi.Tests\Microsoft.OpenApi.Hidi.Tests.csproj", "{6ADC5D41-EDD2-4206-B815-5DFF739C6832}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -56,6 +60,14 @@ Global {1D2E0C6E-B103-4CB6-912E-D56FA1501296}.Debug|Any CPU.Build.0 = Debug|Any CPU {1D2E0C6E-B103-4CB6-912E-D56FA1501296}.Release|Any CPU.ActiveCfg = Release|Any CPU {1D2E0C6E-B103-4CB6-912E-D56FA1501296}.Release|Any CPU.Build.0 = Release|Any CPU + {538936B4-5E14-4EA3-9FD0-F43E2DD014FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {538936B4-5E14-4EA3-9FD0-F43E2DD014FB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {538936B4-5E14-4EA3-9FD0-F43E2DD014FB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {538936B4-5E14-4EA3-9FD0-F43E2DD014FB}.Release|Any CPU.Build.0 = Release|Any CPU + {6ADC5D41-EDD2-4206-B815-5DFF739C6832}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6ADC5D41-EDD2-4206-B815-5DFF739C6832}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6ADC5D41-EDD2-4206-B815-5DFF739C6832}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6ADC5D41-EDD2-4206-B815-5DFF739C6832}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -67,6 +79,8 @@ Global {AD83F991-DBF3-4251-8613-9CC54C826964} = {6357D7FD-2DE4-4900-ADB9-ABC37052040A} {1ED3C2C1-E1E7-4925-B4E6-2D969C3F5237} = {6357D7FD-2DE4-4900-ADB9-ABC37052040A} {1D2E0C6E-B103-4CB6-912E-D56FA1501296} = {6357D7FD-2DE4-4900-ADB9-ABC37052040A} + {538936B4-5E14-4EA3-9FD0-F43E2DD014FB} = {E546B92F-20A8-49C3-8323-4B25BB78F3E1} + {6ADC5D41-EDD2-4206-B815-5DFF739C6832} = {6357D7FD-2DE4-4900-ADB9-ABC37052040A} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {9F171EFC-0DB5-4B10-ABFA-AF48D52CC565} diff --git a/src/Microsoft.OpenApi/Models/OpenApiSchema.cs b/src/Microsoft.OpenApi/Models/OpenApiSchema.cs index 84e03fcb0..310447172 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiSchema.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiSchema.cs @@ -727,7 +727,7 @@ private void SerializeAsV2( // readOnly // In V2 schema if a property is part of required properties of parent schema, // it cannot be marked as readonly. - if (!string.IsNullOrEmpty(propertyName) && propertyName is not null && !parentRequiredProperties.Contains(propertyName)) + if (!parentRequiredProperties.Contains(propertyName ?? string.Empty)) { writer.WriteProperty(name: OpenApiConstants.ReadOnly, value: ReadOnly, defaultValue: false); } diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 39095006a..da64a0482 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -23,7 +23,7 @@ - + From 3611b62558ebf8d25da9b119f39bcb519f6bf957 Mon Sep 17 00:00:00 2001 From: Andrew Omondi Date: Tue, 18 Mar 2025 16:26:25 +0300 Subject: [PATCH 033/984] chore: fix public api --- test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index 6685b34d8..3127fc8ab 100644 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -454,7 +454,6 @@ namespace Microsoft.OpenApi.Models.Interfaces System.Uri? Schema { get; } string? Title { get; } Microsoft.OpenApi.Models.JsonSchemaType? Type { get; } - bool UnEvaluatedProperties { get; } bool UnevaluatedProperties { get; } bool? UniqueItems { get; } System.Collections.Generic.IDictionary? UnrecognizedKeywords { get; } @@ -1391,7 +1390,6 @@ namespace Microsoft.OpenApi.Models.References public System.Uri? Schema { get; } public string? Title { get; } public Microsoft.OpenApi.Models.JsonSchemaType? Type { get; } - public bool UnEvaluatedProperties { get; } public bool UnevaluatedProperties { get; } public bool? UniqueItems { get; } public System.Collections.Generic.IDictionary? UnrecognizedKeywords { get; } From f62e039a2efde04d0c3988b359ca09ab3349a40b Mon Sep 17 00:00:00 2001 From: Romain V Date: Tue, 18 Mar 2025 15:22:04 +0100 Subject: [PATCH 034/984] Merge pull request #2273 from Poltuu/main fix: remove duplicate unused property --- src/Microsoft.OpenApi/Models/OpenApiSchema.cs | 3 --- test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt | 1 - 2 files changed, 4 deletions(-) diff --git a/src/Microsoft.OpenApi/Models/OpenApiSchema.cs b/src/Microsoft.OpenApi/Models/OpenApiSchema.cs index 84e03fcb0..6b0f9258c 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiSchema.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiSchema.cs @@ -102,9 +102,6 @@ public decimal? ExclusiveMinimum /// DO NOT CHANGE THE VISIBILITY OF THIS PROPERTY TO PUBLIC internal bool? IsExclusiveMinimum { get; set; } - /// - public bool UnEvaluatedProperties { get; set; } - /// public JsonSchemaType? Type { get; set; } diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index 3127fc8ab..0d691d05e 100644 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -1057,7 +1057,6 @@ namespace Microsoft.OpenApi.Models public System.Uri? Schema { get; set; } public string? Title { get; set; } public Microsoft.OpenApi.Models.JsonSchemaType? Type { get; set; } - public bool UnEvaluatedProperties { get; set; } public bool UnevaluatedProperties { get; set; } public bool? UniqueItems { get; set; } public System.Collections.Generic.IDictionary? UnrecognizedKeywords { get; set; } From fa8761a6712dcf80b9f5febbb05f06cfc6835343 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Tue, 18 Mar 2025 19:28:11 +0300 Subject: [PATCH 035/984] chore: upgrade package version --- src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index eec5874c4..f86df01d7 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -39,7 +39,7 @@ - + From 9074f40d23644ac98b043ee25e0e3531799f22d4 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Tue, 18 Mar 2025 19:49:57 +0300 Subject: [PATCH 036/984] chore: upgrade OData lib version --- src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index f86df01d7..3d2d9759b 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -38,7 +38,7 @@ - + From 37dc71ae64004e657d8a8b840725822e330bb800 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Tue, 18 Mar 2025 17:24:40 +0000 Subject: [PATCH 037/984] chore(main): release 2.0.0-preview.15 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 9 +++++++++ Directory.Build.props | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 18bc6068c..6053a9c33 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "2.0.0-preview.14" + ".": "2.0.0-preview.15" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index c315bbe44..6812036e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## [2.0.0-preview.15](https://github.com/microsoft/OpenAPI.NET/compare/v2.0.0-preview.14...v2.0.0-preview.15) (2025-03-18) + + +### Bug Fixes + +* Include hidi in solution ([7f4bec8](https://github.com/microsoft/OpenAPI.NET/commit/7f4bec8304771b498e8b0e33c706869ff79fd155)) +* remove duplicate unused property ([f62e039](https://github.com/microsoft/OpenAPI.NET/commit/f62e039a2efde04d0c3988b359ca09ab3349a40b)) +* revert change to exclude hidi in solution ([c3afe4e](https://github.com/microsoft/OpenAPI.NET/commit/c3afe4e8af2526e957940503a31079ed5f027c0a)) + ## [2.0.0-preview.14](https://github.com/microsoft/OpenAPI.NET/compare/v2.0.0-preview.13...v2.0.0-preview.14) (2025-03-18) diff --git a/Directory.Build.props b/Directory.Build.props index 57b0bcda4..e78ae4872 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -12,7 +12,7 @@ https://github.com/Microsoft/OpenAPI.NET © Microsoft Corporation. All rights reserved. OpenAPI .NET - 2.0.0-preview.14 + 2.0.0-preview.15 From 76b9f705c76a86d2bce32d0f87153c59f11caac8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 19 Mar 2025 21:48:27 +0000 Subject: [PATCH 038/984] chore(deps): bump Microsoft.VisualStudio.Threading.Analyzers Bumps [Microsoft.VisualStudio.Threading.Analyzers](https://github.com/microsoft/vs-threading) from 17.13.2 to 17.13.61. - [Release notes](https://github.com/microsoft/vs-threading/releases) - [Commits](https://github.com/microsoft/vs-threading/compare/v17.13.2...v17.13.61) --- updated-dependencies: - dependency-name: Microsoft.VisualStudio.Threading.Analyzers dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .../Microsoft.OpenApi.Workbench.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj index 1bff03a43..5cfd3cfe4 100644 --- a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj +++ b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj @@ -1,4 +1,4 @@ - + net8.0-windows WinExe @@ -9,7 +9,7 @@ NU1903 - + runtime; build; native; contentfiles; analyzers; buildtransitive all From a765acf380135694bbd4d1336bd4beddef6ef808 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Thu, 20 Mar 2025 13:06:16 +0300 Subject: [PATCH 039/984] fix: always serialize security schemes in components --- .../Models/OpenApiComponents.cs | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.OpenApi/Models/OpenApiComponents.cs b/src/Microsoft.OpenApi/Models/OpenApiComponents.cs index 250254212..540664ae5 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiComponents.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiComponents.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Linq; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models.Interfaces; using Microsoft.OpenApi.Models.References; @@ -110,7 +111,7 @@ public void SerializeAsV31(IOpenApiWriter writer) // however if they have cycles, then we will need a component rendered if (writer.GetSettings().InlineLocalReferences) { - RenderComponents(writer, (writer, element) => element.SerializeAsV31(writer)); + RenderComponents(writer, (writer, element) => element.SerializeAsV31(writer), OpenApiSpecVersion.OpenApi3_1); return; } @@ -148,7 +149,7 @@ public void SerializeAsV3(IOpenApiWriter writer) // however if they have cycles, then we will need a component rendered if (writer.GetSettings().InlineLocalReferences) { - RenderComponents(writer, (writer, element) => element.SerializeAsV3(writer)); + RenderComponents(writer, (writer, element) => element.SerializeAsV3(writer), OpenApiSpecVersion.OpenApi3_0); return; } @@ -315,7 +316,7 @@ private void SerializeInternal(IOpenApiWriter writer, OpenApiSpecVersion version writer.WriteEndObject(); } - private void RenderComponents(IOpenApiWriter writer, Action callback) + private void RenderComponents(IOpenApiWriter writer, Action callback, OpenApiSpecVersion version) { var loops = writer.GetSettings().LoopDetector.Loops; writer.WriteStartObject(); @@ -323,6 +324,19 @@ private void RenderComponents(IOpenApiWriter writer, Action + { + if (version is OpenApiSpecVersion.OpenApi3_1) + component.SerializeAsV31(writer); + component.SerializeAsV3(writer); + }); + } writer.WriteEndObject(); } From 01784e4e4a3ce679af9df0b6fc1ed59586eabe53 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Thu, 20 Mar 2025 13:06:36 +0300 Subject: [PATCH 040/984] chore: add test to validate --- .../Models/OpenApiDocumentTests.cs | 43 +++++++++++++++++++ .../Models/Samples/docWithSecurityScheme.yaml | 32 ++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 test/Microsoft.OpenApi.Tests/Models/Samples/docWithSecurityScheme.yaml diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs index 75ad6d086..6c3498007 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs @@ -2179,5 +2179,48 @@ public void SerializeAsThrowsIfVersionIsNotSupported() Assert.Equal("version", actual.ParamName); Assert.Equal(version, actual.ActualValue); } + + [Fact] + public async Task SerializeDocWithSecuritySchemeWithInlineRefererencesWorks() + { + var expected = @"openapi: 3.0.4 +info: + title: Repair Service + version: 1.0.0 +servers: + - url: https://pluginrentu.azurewebsites.net/api +paths: + /repairs: + get: + summary: List all repairs with oauth + description: Returns a list of repairs with their details and images + operationId: listRepairs + responses: + '200': + description: A list of repairs + content: + application/json: + schema: + type: object + security: + - oAuth2AuthCode: [ ] +components: + securitySchemes: + oAuth2AuthCode: + type: oauth2 + description: OAuth configuration for the repair service + flows: + authorizationCode: + authorizationUrl: https://login.microsoftonline.com/2f13b28c-bd4d-43e2-8ae6-48594aaba125/oauth2/v2.0/authorize + tokenUrl: https://login.microsoftonline.com/2f13b28c-bd4d-43e2-8ae6-48594aaba125/oauth2/v2.0/token + scopes: + api://a2a7226d-e8d1-4ded-8c53-dd4c136ff456/repairs_read: Read repair records"; + + var doc = (await OpenApiDocument.LoadAsync("Models/Samples/docWithSecurityScheme.yaml", SettingsFixture.ReaderSettings)).Document; + var stringWriter = new StringWriter(); + doc.SerializeAsV3(new OpenApiYamlWriter(stringWriter, new OpenApiWriterSettings { InlineLocalReferences = true })); + var actual = stringWriter.ToString(); + Assert.Equal(expected.MakeLineBreaksEnvironmentNeutral(), actual.MakeLineBreaksEnvironmentNeutral()); + } } } diff --git a/test/Microsoft.OpenApi.Tests/Models/Samples/docWithSecurityScheme.yaml b/test/Microsoft.OpenApi.Tests/Models/Samples/docWithSecurityScheme.yaml new file mode 100644 index 000000000..ee888cb2c --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/Samples/docWithSecurityScheme.yaml @@ -0,0 +1,32 @@ +openapi: 3.0.0 +info: + title: Repair Service + version: 1.0.0 +servers: + - url: https://pluginrentu.azurewebsites.net/api +components: + securitySchemes: + oAuth2AuthCode: + type: oauth2 + description: OAuth configuration for the repair service + flows: + authorizationCode: + authorizationUrl: https://login.microsoftonline.com/2f13b28c-bd4d-43e2-8ae6-48594aaba125/oauth2/v2.0/authorize + tokenUrl: https://login.microsoftonline.com/2f13b28c-bd4d-43e2-8ae6-48594aaba125/oauth2/v2.0/token + scopes: + api://a2a7226d-e8d1-4ded-8c53-dd4c136ff456/repairs_read: Read repair records +paths: + /repairs: + get: + operationId: listRepairs + summary: List all repairs with oauth + description: Returns a list of repairs with their details and images + security: + - oAuth2AuthCode: [] + responses: + '200': + description: A list of repairs + content: + application/json: + schema: + type: object \ No newline at end of file From fd4c3681a8746d400706ea6688b48852bf2143ae Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Thu, 20 Mar 2025 14:31:05 +0300 Subject: [PATCH 041/984] chore: copy file to output directory --- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index da64a0482..e1d0e3752 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -1,4 +1,4 @@ - + net8.0 false @@ -51,6 +51,10 @@ PreserveNewest + + PreserveNewest + + \ No newline at end of file From d532b9d2b1b282f9307f45267380ade3571187ba Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Thu, 20 Mar 2025 14:27:41 +0000 Subject: [PATCH 042/984] chore(main): release 2.0.0-preview.16 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 8 ++++++++ Directory.Build.props | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 6053a9c33..4c324336f 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "2.0.0-preview.15" + ".": "2.0.0-preview.16" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 6812036e2..f590fa76d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## [2.0.0-preview.16](https://github.com/microsoft/OpenAPI.NET/compare/v2.0.0-preview.15...v2.0.0-preview.16) (2025-03-20) + + +### Bug Fixes + +* always serialize security schemes in components ([3aac661](https://github.com/microsoft/OpenAPI.NET/commit/3aac661ca2e8050136c423f2835fcdd3a9096482)) +* always serialize security schemes in components ([a765acf](https://github.com/microsoft/OpenAPI.NET/commit/a765acf380135694bbd4d1336bd4beddef6ef808)) + ## [2.0.0-preview.15](https://github.com/microsoft/OpenAPI.NET/compare/v2.0.0-preview.14...v2.0.0-preview.15) (2025-03-18) diff --git a/Directory.Build.props b/Directory.Build.props index e78ae4872..36d681cf5 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -12,7 +12,7 @@ https://github.com/Microsoft/OpenAPI.NET © Microsoft Corporation. All rights reserved. OpenAPI .NET - 2.0.0-preview.15 + 2.0.0-preview.16 From 521d636e2c437c25e1758e9f6a22793d74adf2d7 Mon Sep 17 00:00:00 2001 From: Stefan Cuypers <32466116+StefanCuypers@users.noreply.github.com> Date: Fri, 28 Mar 2025 13:23:25 +0100 Subject: [PATCH 043/984] fix: Empty tag causes error generating Kiota client #2283 (#2286) * Fix issue Empty tag causes error generating Kiota client #2283 * fix: empty tag causes Exception generating Kiota client #2283 * fix: empty tag causes Exception generating Kiota client #2283 --- .../Reader/V2/OpenApiOperationDeserializer.cs | 14 +++++- .../Reader/V3/OpenApiOperationDeserializer.cs | 15 +++++- .../V31/OpenApiOperationDeserializer.cs | 15 +++++- .../V31Tests/OpenApiDocumentTests.cs | 9 ++++ .../documentWithEmptyTags.json | 50 +++++++++++++++++++ 5 files changed, 97 insertions(+), 6 deletions(-) create mode 100644 test/Microsoft.OpenApi.Readers.Tests/V31Tests/Samples/OpenApiDocument/documentWithEmptyTags.json diff --git a/src/Microsoft.OpenApi/Reader/V2/OpenApiOperationDeserializer.cs b/src/Microsoft.OpenApi/Reader/V2/OpenApiOperationDeserializer.cs index 207845c7f..4bd28a18d 100644 --- a/src/Microsoft.OpenApi/Reader/V2/OpenApiOperationDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V2/OpenApiOperationDeserializer.cs @@ -23,8 +23,18 @@ internal static partial class OpenApiV2Deserializer new() { { - "tags", (o, n, doc) => { - if (n.CreateSimpleList((valueNode, doc) => LoadTagByReference(valueNode.GetScalarValue(), doc), doc) is {Count: > 0} tags) + "tags", (o, n, doc) => { + if (n.CreateSimpleList( + (valueNode, doc) => + { + var val = valueNode.GetScalarValue(); + if (string.IsNullOrEmpty(val)) + return null; // Avoid exception on empty tag, we'll remove these from the list further on + return LoadTagByReference(val , doc); + }, + doc) + // Filter out empty tags instead of excepting on them + .OfType().ToList() is {Count: > 0} tags) { o.Tags = new HashSet(tags, OpenApiTagComparer.Instance); } diff --git a/src/Microsoft.OpenApi/Reader/V3/OpenApiOperationDeserializer.cs b/src/Microsoft.OpenApi/Reader/V3/OpenApiOperationDeserializer.cs index 00fdeb3ee..eb971da7c 100644 --- a/src/Microsoft.OpenApi/Reader/V3/OpenApiOperationDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V3/OpenApiOperationDeserializer.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Linq; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.References; @@ -20,8 +21,18 @@ internal static partial class OpenApiV3Deserializer new() { { - "tags", (o, n, doc) => { - if (n.CreateSimpleList((valueNode, doc) => LoadTagByReference(valueNode.GetScalarValue(), doc), doc) is {Count: > 0} tags) + "tags", (o, n, doc) => { + if (n.CreateSimpleList( + (valueNode, doc) => + { + var val = valueNode.GetScalarValue(); + if (string.IsNullOrEmpty(val)) + return null; // Avoid exception on empty tag, we'll remove these from the list further on + return LoadTagByReference(val , doc); + }, + doc) + // Filter out empty tags instead of excepting on them + .OfType().ToList() is {Count: > 0} tags) { o.Tags = new HashSet(tags, OpenApiTagComparer.Instance); } diff --git a/src/Microsoft.OpenApi/Reader/V31/OpenApiOperationDeserializer.cs b/src/Microsoft.OpenApi/Reader/V31/OpenApiOperationDeserializer.cs index cf0b4856c..abf35545b 100644 --- a/src/Microsoft.OpenApi/Reader/V31/OpenApiOperationDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V31/OpenApiOperationDeserializer.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.References; @@ -17,8 +18,18 @@ internal static partial class OpenApiV31Deserializer new() { { - "tags", (o, n, doc) => { - if (n.CreateSimpleList((valueNode, doc) => LoadTagByReference(valueNode.GetScalarValue(), doc), doc) is {Count: > 0} tags) + "tags", (o, n, doc) => { + if (n.CreateSimpleList( + (valueNode, doc) => + { + var val = valueNode.GetScalarValue(); + if (string.IsNullOrEmpty(val)) + return null; // Avoid exception on empty tag, we'll remove these from the list further on + return LoadTagByReference(val , doc); + }, + doc) + // Filter out empty tags instead of excepting on them + .OfType().ToList() is {Count: > 0} tags) { o.Tags = new HashSet(tags, OpenApiTagComparer.Instance); } diff --git a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentTests.cs index 2cab4c37b..167d59cc7 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentTests.cs @@ -570,6 +570,15 @@ public async Task ParseDocumentWith31PropertiesWorks() await Verifier.Verify(actual); } + [Fact] + public async Task ParseDocumentWithEmptyTagsWorks() + { + var path = Path.Combine(SampleFolderPath, "documentWithEmptyTags.json"); + var doc = (await OpenApiDocument.LoadAsync(path, SettingsFixture.ReaderSettings)).Document; + + doc.Paths["/groups"].Operations[HttpMethod.Get].Tags.Should().BeNull("Empty tags are ignored, so we should not have any tags"); + } + [Fact] public void ParseEmptyMemoryStreamThrowsAnArgumentException() { diff --git a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/Samples/OpenApiDocument/documentWithEmptyTags.json b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/Samples/OpenApiDocument/documentWithEmptyTags.json new file mode 100644 index 000000000..d9d5d4290 --- /dev/null +++ b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/Samples/OpenApiDocument/documentWithEmptyTags.json @@ -0,0 +1,50 @@ +{ + "openapi": "3.1.0", + "info": { + "description": "Groups API", + "title": "Groups", + "version": "1.0" + }, + "paths": { + "/groups": { + "get": { + "operationId": "getGroups", + "parameters": [ + { + "description": "Zero-based page index (0..N)", + "example": 0, + "in": "query", + "name": "page", + "required": false, + "schema": { + "type": "integer", + "format": "int32", + "default": 0, + "minimum": 0 + } + } + ], + "responses": { + "200": { + "content": { "application/json": { "schema": { "$ref": "#/components/schemas/PaginatedGroup" } } } + } + }, + "tags": [ "" ] + } + } + }, + "components": { + "schemas": { + "PaginatedGroup": { + "type": "object", + "properties": { + "number": { + "type": "integer", + "format": "int32", + "description": "The number of the current page." + } + } + } + } + } +} From 945c75499b8e1f11354d4efab55e408fe7ac6bad Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Fri, 28 Mar 2025 13:57:55 -0400 Subject: [PATCH 044/984] chore: cleans up nullable directives Signed-off-by: Vincent Biret --- src/Microsoft.OpenApi/Attributes/TrimmingAttributes.cs | 2 -- src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs | 3 --- src/Microsoft.OpenApi/Models/OpenApiComponents.cs | 2 -- src/Microsoft.OpenApi/Models/OpenApiDocument.cs | 2 -- src/Microsoft.OpenApi/Models/OpenApiMediaType.cs | 2 -- src/Microsoft.OpenApi/Models/OpenApiOperation.cs | 2 -- src/Microsoft.OpenApi/Models/OpenApiReference.cs | 2 -- src/Microsoft.OpenApi/OpenApiTagComparer.cs | 2 -- src/Microsoft.OpenApi/Services/OpenApiWalker.cs | 2 -- src/Microsoft.OpenApi/Services/OpenApiWorkspace.cs | 2 -- src/Microsoft.OpenApi/Writers/OpenApiWriterExtensions.cs | 2 -- 11 files changed, 23 deletions(-) diff --git a/src/Microsoft.OpenApi/Attributes/TrimmingAttributes.cs b/src/Microsoft.OpenApi/Attributes/TrimmingAttributes.cs index 538ed521e..e93686ddd 100644 --- a/src/Microsoft.OpenApi/Attributes/TrimmingAttributes.cs +++ b/src/Microsoft.OpenApi/Attributes/TrimmingAttributes.cs @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. -#nullable enable - // This collection of attribute definitions are helpers for accessing trim-related attributes in // projects targeting .NET 6 or lower. Since the trimmer queries for these attributes by name, having // these attributes source included is sufficient for the trimmer to recognize them. For more information diff --git a/src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs b/src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs index 3ae417022..9d6dc60d0 100644 --- a/src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs +++ b/src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs @@ -14,7 +14,6 @@ namespace Microsoft.OpenApi.Extensions /// public static class OpenApiTypeMapper { -#nullable enable /// /// Maps a JsonSchema data type to an identifier. /// @@ -75,8 +74,6 @@ internal static string ToSingleIdentifier(this JsonSchemaType schemaType) return schemaType.ToIdentifiersInternal().Single(); } -#nullable restore - /// /// Converts a schema type's identifier into the enum equivalent /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiComponents.cs b/src/Microsoft.OpenApi/Models/OpenApiComponents.cs index 540664ae5..c3b762088 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiComponents.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiComponents.cs @@ -9,8 +9,6 @@ using Microsoft.OpenApi.Models.References; using Microsoft.OpenApi.Writers; -#nullable enable - namespace Microsoft.OpenApi.Models { /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs index 0f69409d6..e5f82e9cb 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs @@ -17,8 +17,6 @@ using Microsoft.OpenApi.Services; using Microsoft.OpenApi.Writers; -#nullable enable - namespace Microsoft.OpenApi.Models { /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs b/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs index 7ba469bc6..4c08ccccb 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs @@ -10,8 +10,6 @@ using Microsoft.OpenApi.Models.Interfaces; using Microsoft.OpenApi.Writers; -#nullable enable - namespace Microsoft.OpenApi.Models { /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiOperation.cs b/src/Microsoft.OpenApi/Models/OpenApiOperation.cs index 5375fb031..23a98f3d2 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiOperation.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiOperation.cs @@ -9,8 +9,6 @@ using Microsoft.OpenApi.Models.References; using Microsoft.OpenApi.Writers; -#nullable enable - namespace Microsoft.OpenApi.Models { /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiReference.cs b/src/Microsoft.OpenApi/Models/OpenApiReference.cs index ae79cc10f..0e05ec89d 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiReference.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiReference.cs @@ -281,10 +281,8 @@ internal void EnsureHostDocumentIsSet(OpenApiDocument currentDocument) Utils.CheckArgumentNull(currentDocument); hostDocument ??= currentDocument; } - #nullable enable private static string? GetPropertyValueFromNode(JsonObject jsonObject, string key) => jsonObject.TryGetPropertyValue(key, out var valueNode) && valueNode is JsonValue valueCast && valueCast.TryGetValue(out var strValue) ? strValue : null; - #nullable restore internal void SetSummaryAndDescriptionFromMapNode(MapNode mapNode) { var (description, summary) = mapNode.JsonNode switch { diff --git a/src/Microsoft.OpenApi/OpenApiTagComparer.cs b/src/Microsoft.OpenApi/OpenApiTagComparer.cs index 6652dd5ba..dfa89e87f 100644 --- a/src/Microsoft.OpenApi/OpenApiTagComparer.cs +++ b/src/Microsoft.OpenApi/OpenApiTagComparer.cs @@ -4,7 +4,6 @@ namespace Microsoft.OpenApi; -#nullable enable /// /// This comparer is used to maintain a globally unique list of tags encountered /// in a particular OpenAPI document. @@ -44,4 +43,3 @@ public bool Equals(IOpenApiTag? x, IOpenApiTag? y) /// public int GetHashCode(IOpenApiTag obj) => string.IsNullOrEmpty(obj?.Name) ? 0 : StringComparer.GetHashCode(obj!.Name); } -#nullable restore diff --git a/src/Microsoft.OpenApi/Services/OpenApiWalker.cs b/src/Microsoft.OpenApi/Services/OpenApiWalker.cs index cf07356d3..49ac98079 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiWalker.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiWalker.cs @@ -130,7 +130,6 @@ internal void Walk(OpenApiExternalDocs? externalDocs) _visitor.Visit(externalDocs); } -#nullable enable /// /// Visits and child objects /// @@ -256,7 +255,6 @@ internal void Walk(OpenApiComponents? components) Walk(components as IOpenApiExtensible); } -#nullable restore /// /// Visits and child objects /// diff --git a/src/Microsoft.OpenApi/Services/OpenApiWorkspace.cs b/src/Microsoft.OpenApi/Services/OpenApiWorkspace.cs index d668626db..a8ffde23d 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiWorkspace.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiWorkspace.cs @@ -281,7 +281,6 @@ public bool Contains(string location) return _IOpenApiReferenceableRegistry.ContainsKey(key) || _artifactsRegistry.ContainsKey(key); } -#nullable enable /// /// Resolves a reference given a key. /// @@ -307,7 +306,6 @@ public bool Contains(string location) return default; } -#nullable restore private Uri? ToLocationUrl(string location) { diff --git a/src/Microsoft.OpenApi/Writers/OpenApiWriterExtensions.cs b/src/Microsoft.OpenApi/Writers/OpenApiWriterExtensions.cs index ad84d5537..3df27f6d7 100644 --- a/src/Microsoft.OpenApi/Writers/OpenApiWriterExtensions.cs +++ b/src/Microsoft.OpenApi/Writers/OpenApiWriterExtensions.cs @@ -126,7 +126,6 @@ public static void WriteProperty(this IOpenApiWriter writer, string name, T v writer.WriteValue(value); } -#nullable enable /// /// Write the optional Open API object/element. /// @@ -179,7 +178,6 @@ public static void WriteRequiredObject( writer.WriteEndObject(); } } -#nullable restore /// /// Write the optional of collection string. From b9df4ac1ae42f849dd528d8f6987922a1b3bc3d1 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Mon, 31 Mar 2025 10:07:52 -0400 Subject: [PATCH 045/984] chore: minor refactoring Signed-off-by: Vincent Biret --- src/Microsoft.OpenApi/Validations/ValidationRule.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi/Validations/ValidationRule.cs b/src/Microsoft.OpenApi/Validations/ValidationRule.cs index a72beb5c1..2c2ea3e88 100644 --- a/src/Microsoft.OpenApi/Validations/ValidationRule.cs +++ b/src/Microsoft.OpenApi/Validations/ValidationRule.cs @@ -66,12 +66,11 @@ internal override void Evaluate(IValidationContext context, object item) return; } - if (item is not T) + if (item is not T typedItem) { throw new ArgumentException(string.Format(SRResource.InputItemShouldBeType, typeof(T).FullName)); } - var typedItem = (T)item; this._validate(context, typedItem); } } From c5b69fed9c413a6399c36e0f543e1019faac77e6 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Mon, 31 Mar 2025 14:04:41 -0400 Subject: [PATCH 046/984] fix: hidi fails to parse yaml files when fixing references --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index 9f026c3e4..8b412d14f 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -438,7 +438,10 @@ private static async Task ParseOpenApiAsync(string openApiFile, bool var sb = new StringBuilder(); document.SerializeAsV3(new OpenApiYamlWriter(new StringWriter(sb))); - var doc = OpenApiDocument.Parse(sb.ToString(), format).Document; + var settings = new OpenApiReaderSettings(); + settings.AddYamlReader(); + + var doc = OpenApiDocument.Parse(sb.ToString(), format, settings).Document; return doc; } From b4877f674ad1a240a367390d40d122eebccc0b20 Mon Sep 17 00:00:00 2001 From: Michael Wamae <68949852+Michael-Wamae@users.noreply.github.com> Date: Tue, 1 Apr 2025 16:12:14 +0300 Subject: [PATCH 047/984] Merge pull request #2280 from microsoft/mw/update-discriminator-mappings feat: discriminator mappings now use schema references --- .../Models/OpenApiDiscriminator.cs | 13 +++++++++--- .../V3/OpenApiDiscriminatorDeserializer.cs | 10 +++++++++- .../Reader/V3/OpenApiV3VersionService.cs | 7 +++---- .../V31/OpenApiDiscriminatorDeserializer.cs | 12 +++++++++-- .../Reader/V31/OpenApiV31VersionService.cs | 7 +++---- .../V3Tests/OpenApiDiscriminatorTests.cs | 20 +++++++++++-------- .../basicDiscriminator.yaml | 3 ++- .../PublicApi/PublicApi.approved.txt | 2 +- 8 files changed, 50 insertions(+), 24 deletions(-) diff --git a/src/Microsoft.OpenApi/Models/OpenApiDiscriminator.cs b/src/Microsoft.OpenApi/Models/OpenApiDiscriminator.cs index 3bbae4561..32a828c5b 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiDiscriminator.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiDiscriminator.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using Microsoft.OpenApi.Interfaces; +using Microsoft.OpenApi.Models.References; using Microsoft.OpenApi.Writers; namespace Microsoft.OpenApi.Models @@ -20,7 +21,7 @@ public class OpenApiDiscriminator : IOpenApiSerializable, IOpenApiExtensible /// /// An object to hold mappings between payload values and schema names or references. /// - public IDictionary? Mapping { get; set; } = new Dictionary(); + public IDictionary? Mapping { get; set; } = new Dictionary(); /// /// This object MAY be extended with Specification Extensions. @@ -38,7 +39,7 @@ public OpenApiDiscriminator() { } public OpenApiDiscriminator(OpenApiDiscriminator discriminator) { PropertyName = discriminator?.PropertyName ?? PropertyName; - Mapping = discriminator?.Mapping != null ? new Dictionary(discriminator.Mapping) : null; + Mapping = discriminator?.Mapping != null ? new Dictionary(discriminator.Mapping) : null; Extensions = discriminator?.Extensions != null ? new Dictionary(discriminator.Extensions) : null; } @@ -80,7 +81,13 @@ private void SerializeInternal(IOpenApiWriter writer) writer.WriteProperty(OpenApiConstants.PropertyName, PropertyName); // mapping - writer.WriteOptionalMap(OpenApiConstants.Mapping, Mapping, (w, s) => w.WriteValue(s)); + writer.WriteOptionalMap(OpenApiConstants.Mapping, Mapping, (w, s) => + { + if (!string.IsNullOrEmpty(s.Reference.ReferenceV3) && s.Reference.ReferenceV3 is not null) + { + w.WriteValue(s.Reference.ReferenceV3); + } + }); } /// diff --git a/src/Microsoft.OpenApi/Reader/V3/OpenApiDiscriminatorDeserializer.cs b/src/Microsoft.OpenApi/Reader/V3/OpenApiDiscriminatorDeserializer.cs index 1493283c0..21d8b4171 100644 --- a/src/Microsoft.OpenApi/Reader/V3/OpenApiDiscriminatorDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V3/OpenApiDiscriminatorDeserializer.cs @@ -1,8 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. +using System; using System.Linq; using Microsoft.OpenApi.Models; +using Microsoft.OpenApi.Models.References; using Microsoft.OpenApi.Reader.ParseNodes; namespace Microsoft.OpenApi.Reader.V3 @@ -22,7 +24,7 @@ internal static partial class OpenApiV3Deserializer }, { "mapping", - (o, n, _) => o.Mapping = n.CreateSimpleMap(LoadString).Where(kv => kv.Value is not null).ToDictionary(kv => kv.Key, kv => kv.Value!) + (o, n, doc) => o.Mapping = n.CreateSimpleMap((node) => LoadMapping(node, doc)) } }; @@ -40,5 +42,11 @@ public static OpenApiDiscriminator LoadDiscriminator(ParseNode node, OpenApiDocu return discriminator; } + public static OpenApiSchemaReference LoadMapping(ParseNode node, OpenApiDocument hostDocument) + { + var pointer = node.GetScalarValue() ?? throw new InvalidOperationException("Could not get a pointer reference"); + var reference = GetReferenceIdAndExternalResource(pointer); + return new OpenApiSchemaReference(reference.Item1, hostDocument, reference.Item2); + } } } diff --git a/src/Microsoft.OpenApi/Reader/V3/OpenApiV3VersionService.cs b/src/Microsoft.OpenApi/Reader/V3/OpenApiV3VersionService.cs index d568b327c..364eb1d54 100644 --- a/src/Microsoft.OpenApi/Reader/V3/OpenApiV3VersionService.cs +++ b/src/Microsoft.OpenApi/Reader/V3/OpenApiV3VersionService.cs @@ -5,11 +5,9 @@ using System.Collections.Generic; using System.Linq; using Microsoft.OpenApi.Any; -using Microsoft.OpenApi.Exceptions; -using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; -using Microsoft.OpenApi.Properties; +using Microsoft.OpenApi.Models.References; using Microsoft.OpenApi.Reader.ParseNodes; namespace Microsoft.OpenApi.Reader.V3 @@ -62,7 +60,8 @@ public OpenApiV3VersionService(OpenApiDiagnostic diagnostic) [typeof(OpenApiServer)] = OpenApiV3Deserializer.LoadServer, [typeof(OpenApiServerVariable)] = OpenApiV3Deserializer.LoadServerVariable, [typeof(OpenApiTag)] = OpenApiV3Deserializer.LoadTag, - [typeof(OpenApiXml)] = OpenApiV3Deserializer.LoadXml + [typeof(OpenApiXml)] = OpenApiV3Deserializer.LoadXml, + [typeof(OpenApiSchemaReference)] = OpenApiV3Deserializer.LoadMapping }; public OpenApiDocument LoadDocument(RootNode rootNode) diff --git a/src/Microsoft.OpenApi/Reader/V31/OpenApiDiscriminatorDeserializer.cs b/src/Microsoft.OpenApi/Reader/V31/OpenApiDiscriminatorDeserializer.cs index e94f408d2..7eb288fd2 100644 --- a/src/Microsoft.OpenApi/Reader/V31/OpenApiDiscriminatorDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V31/OpenApiDiscriminatorDeserializer.cs @@ -2,6 +2,7 @@ using System.Linq; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; +using Microsoft.OpenApi.Models.References; using Microsoft.OpenApi.Reader.ParseNodes; namespace Microsoft.OpenApi.Reader.V31 @@ -22,9 +23,9 @@ internal static partial class OpenApiV31Deserializer } }, { - "mapping", (o, n, _) => + "mapping", (o, n, doc) => { - o.Mapping = n.CreateSimpleMap(LoadString).Where(kv => kv.Value is not null).ToDictionary(kv => kv.Key, kv => kv.Value!); + o.Mapping = n.CreateSimpleMap((node) => LoadMapping(node, doc)); } } }; @@ -47,5 +48,12 @@ public static OpenApiDiscriminator LoadDiscriminator(ParseNode node, OpenApiDocu return discriminator; } + + public static OpenApiSchemaReference LoadMapping(ParseNode node, OpenApiDocument hostDocument) + { + var pointer = node.GetScalarValue() ?? throw new InvalidOperationException("Could not get a pointer reference"); + var reference = GetReferenceIdAndExternalResource(pointer); + return new OpenApiSchemaReference(reference.Item1, hostDocument, reference.Item2); + } } } diff --git a/src/Microsoft.OpenApi/Reader/V31/OpenApiV31VersionService.cs b/src/Microsoft.OpenApi/Reader/V31/OpenApiV31VersionService.cs index bb6cac930..3e010be9b 100644 --- a/src/Microsoft.OpenApi/Reader/V31/OpenApiV31VersionService.cs +++ b/src/Microsoft.OpenApi/Reader/V31/OpenApiV31VersionService.cs @@ -5,11 +5,9 @@ using System.Collections.Generic; using System.Linq; using Microsoft.OpenApi.Any; -using Microsoft.OpenApi.Exceptions; -using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; -using Microsoft.OpenApi.Properties; +using Microsoft.OpenApi.Models.References; using Microsoft.OpenApi.Reader.ParseNodes; using Microsoft.OpenApi.Reader.V3; @@ -61,7 +59,8 @@ public OpenApiV31VersionService(OpenApiDiagnostic diagnostic) [typeof(OpenApiServer)] = OpenApiV31Deserializer.LoadServer, [typeof(OpenApiServerVariable)] = OpenApiV31Deserializer.LoadServerVariable, [typeof(OpenApiTag)] = OpenApiV31Deserializer.LoadTag, - [typeof(OpenApiXml)] = OpenApiV31Deserializer.LoadXml + [typeof(OpenApiXml)] = OpenApiV31Deserializer.LoadXml, + [typeof(OpenApiSchemaReference)] = OpenApiV31Deserializer.LoadMapping }; public OpenApiDocument LoadDocument(RootNode rootNode) diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDiscriminatorTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDiscriminatorTests.cs index 1629e1939..f1b047f08 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDiscriminatorTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDiscriminatorTests.cs @@ -1,9 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. +using System; using System.IO; using System.Threading.Tasks; using Microsoft.OpenApi.Models; +using Microsoft.OpenApi.Models.References; using Microsoft.OpenApi.Reader; using Xunit; @@ -25,19 +27,21 @@ public async Task ParseBasicDiscriminatorShouldSucceed() memoryStream.Position = 0; // Act - var discriminator = OpenApiModelFactory.Load(memoryStream, OpenApiSpecVersion.OpenApi3_0, OpenApiConstants.Yaml, new(), out var diagnostic, SettingsFixture.ReaderSettings); + var openApiDocument = new OpenApiDocument(); + var discriminator = OpenApiModelFactory.Load(memoryStream, OpenApiSpecVersion.OpenApi3_0, OpenApiConstants.Yaml, openApiDocument, out var diagnostic, SettingsFixture.ReaderSettings); // Assert Assert.Equivalent( - new OpenApiDiscriminator - { - PropertyName = "pet_type", - Mapping = + new OpenApiDiscriminator + { + PropertyName = "pet_type", + Mapping = { - ["puppy"] = "#/components/schemas/Dog", - ["kitten"] = "Cat" + ["puppy"] = new OpenApiSchemaReference("Dog", openApiDocument), + ["kitten"] = new OpenApiSchemaReference("Cat" , openApiDocument, "https://gigantic-server.com/schemas/animals.json"), + ["monster"] = new OpenApiSchemaReference("schema.json" , openApiDocument, "https://gigantic-server.com/schemas/Monster/schema.json") } - }, discriminator); + }, discriminator); } } } diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/Samples/OpenApiDiscriminator/basicDiscriminator.yaml b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/Samples/OpenApiDiscriminator/basicDiscriminator.yaml index 7397462f3..21e6adc6c 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/Samples/OpenApiDiscriminator/basicDiscriminator.yaml +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/Samples/OpenApiDiscriminator/basicDiscriminator.yaml @@ -1,4 +1,5 @@ propertyName: pet_type mapping: puppy: '#/components/schemas/Dog' - kitten: Cat \ No newline at end of file + kitten: https://gigantic-server.com/schemas/animals.json#/components/schemas/Cat + monster: https://gigantic-server.com/schemas/Monster/schema.json \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index 0d691d05e..755a9e17e 100644 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -699,7 +699,7 @@ namespace Microsoft.OpenApi.Models public OpenApiDiscriminator() { } public OpenApiDiscriminator(Microsoft.OpenApi.Models.OpenApiDiscriminator discriminator) { } public System.Collections.Generic.IDictionary? Extensions { get; set; } - public System.Collections.Generic.IDictionary? Mapping { get; set; } + public System.Collections.Generic.IDictionary? Mapping { get; set; } public string? PropertyName { get; set; } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } From 48ea5e1cc5e38949bc0481e35ef38797f678d973 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Tue, 1 Apr 2025 15:31:17 -0400 Subject: [PATCH 048/984] security: aligns code owners with security team --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 5bb7a32bd..af656d490 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1 +1 @@ -* @irvinesunday @darrelmiller @gavinbarron @millicentachieng @MaggieKimani1 @andrueastman @baywet +* @microsoft/openapi-write From 3534a6586f0e163464bf187af8c657cb74de7259 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 2 Apr 2025 08:03:07 -0400 Subject: [PATCH 049/984] chore(deps): bump Verify.Xunit from 28.16.0 to 29.1.0 (#2297) Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 28.16.0 to 29.1.0. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/28.16.0...29.1.0) --- updated-dependencies: - dependency-name: Verify.Xunit dependency-version: 29.1.0 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index e1d0e3752..bd3f05211 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -1,4 +1,4 @@ - + net8.0 false @@ -15,7 +15,7 @@ - + From 10c64e18804a58066c46909c0ac968a624cd5f1f Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Wed, 2 Apr 2025 11:16:02 -0400 Subject: [PATCH 050/984] chore: upgrades yoko to the latest preview --- src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index 3d2d9759b..5bc72d2c5 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -38,7 +38,7 @@ - + From 47f10d323e78b9e6caa757c0d2efa378a19fc28c Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Mon, 7 Apr 2025 17:14:47 +0300 Subject: [PATCH 051/984] fix: set format to binary for file uploads (#2305) * fix: set format to binary for file uploads * chore: ordinal comparison --------- Co-authored-by: Vincent Biret --- .../Reader/V2/OpenApiParameterDeserializer.cs | 9 ++++-- .../V2Tests/OpenApiParameterTests.cs | 29 +++++++++++++++++ .../OpenApiParameter/formDataParameter.json | 32 +++++++++++++++++++ 3 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 test/Microsoft.OpenApi.Readers.Tests/V2Tests/Samples/OpenApiParameter/formDataParameter.json diff --git a/src/Microsoft.OpenApi/Reader/V2/OpenApiParameterDeserializer.cs b/src/Microsoft.OpenApi/Reader/V2/OpenApiParameterDeserializer.cs index 61f3b49b1..a074ef242 100644 --- a/src/Microsoft.OpenApi/Reader/V2/OpenApiParameterDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V2/OpenApiParameterDeserializer.cs @@ -72,8 +72,13 @@ internal static partial class OpenApiV2Deserializer { var type = n.GetScalarValue(); if (type != null) - { - GetOrCreateSchema(o).Type = type.ToJsonSchemaType(); + { + var schema = GetOrCreateSchema(o); + schema.Type = type.ToJsonSchemaType(); + if ("file".Equals(type, StringComparison.OrdinalIgnoreCase)) + { + schema.Format = "binary"; + } } } }, diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiParameterTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiParameterTests.cs index aa11d5137..b20c27761 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiParameterTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiParameterTests.cs @@ -8,6 +8,8 @@ using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Reader.ParseNodes; using Microsoft.OpenApi.Reader.V2; +using Microsoft.OpenApi.Tests; +using Microsoft.OpenApi.Writers; using Xunit; namespace Microsoft.OpenApi.Readers.Tests.V2Tests @@ -279,5 +281,32 @@ public void ParseParameterWithEnumShouldSucceed() .Excluding((IMemberInfo memberInfo) => memberInfo.Path.EndsWith("Parent"))); } + + [Fact] + public void ParseFormDataParameterShouldSucceed() + { + // Arrange + var expected = @"{ + ""type"": ""string"", + ""description"": ""file to upload"", + ""format"": ""binary"" +}"; + MapNode node; + using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "formDataParameter.json"))) + { + node = TestHelper.CreateYamlMapNode(stream); + } + + // Act + var operation = OpenApiV2Deserializer.LoadOperation(node, new()); + var schema = operation.RequestBody?.Content["multipart/form-data"].Schema.Properties["file"]; + var writer = new StringWriter(); + schema.SerializeAsV2(new OpenApiJsonWriter(writer)); + var json = writer.ToString(); + + // Assert + Assert.Equal("binary", schema.Format); + Assert.Equal(expected.MakeLineBreaksEnvironmentNeutral(), json.MakeLineBreaksEnvironmentNeutral()); + } } } diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/Samples/OpenApiParameter/formDataParameter.json b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/Samples/OpenApiParameter/formDataParameter.json new file mode 100644 index 000000000..45597c012 --- /dev/null +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/Samples/OpenApiParameter/formDataParameter.json @@ -0,0 +1,32 @@ +{ + "tags": [ "pet" ], + "summary": "uploads an image", + "description": "", + "operationId": "uploadFile", + "consumes": [ "multipart/form-data" ], + "produces": [ "application/json" ], + "parameters": [ + { + "name": "petId", + "in": "path", + "description": "ID of pet to update", + "required": true, + "type": "integer", + "format": "int64" + }, + { + "name": "additionalMetadata", + "in": "formData", + "description": "Additional data to pass to server", + "required": false, + "type": "string" + }, + { + "name": "file", + "in": "formData", + "description": "file to upload", + "required": false, + "type": "file" + } + ] +} \ No newline at end of file From 6f5bc4a16185aeae2bf81d03824080efe8e1cfee Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Apr 2025 23:30:55 +0000 Subject: [PATCH 052/984] chore(deps): bump Verify.Xunit from 29.1.0 to 29.2.0 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 29.1.0 to 29.2.0. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/29.1.0...29.2.0) --- updated-dependencies: - dependency-name: Verify.Xunit dependency-version: 29.2.0 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 bd3f05211..9355e19da 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -15,7 +15,7 @@ - + From ac667560a951bef2824851c208c55ba070e96163 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 8 Apr 2025 20:55:14 +0300 Subject: [PATCH 053/984] fix: read (Exclusive)Maximum and (Exclusive)Minimum values as strings and write their raw values during serialization (#2309) * fix: read (Exclusive)Maximum and (Exclusive)Minimum values as strings and write their raw values * chore: clean up tests * chore: update public API * chore: remove bang operators for consistency * chore: remove depracated class and tests --- .../Models/Interfaces/IOpenApiSchema.cs | 8 +-- src/Microsoft.OpenApi/Models/OpenApiSchema.cs | 51 ++++++++++--------- .../References/OpenApiSchemaReference.cs | 8 +-- .../Reader/ParseNodes/ParserHelper.cs | 35 ------------- .../Reader/V2/OpenApiHeaderDeserializer.cs | 8 +-- .../Reader/V2/OpenApiParameterDeserializer.cs | 8 +-- .../Reader/V2/OpenApiSchemaDeserializer.cs | 8 +-- .../Reader/V3/OpenApiSchemaDeserializer.cs | 10 ++-- .../Reader/V31/OpenApiSchemaDeserializer.cs | 12 ++--- .../ParseNodes/ParserHelperTests.cs | 25 --------- .../V2Tests/OpenApiDocumentTests.cs | 4 +- .../V31Tests/OpenApiSchemaTests.cs | 8 +-- .../V3Tests/OpenApiSchemaTests.cs | 6 +-- .../Models/OpenApiOperationTests.cs | 16 +++--- .../Models/OpenApiSchemaTests.cs | 8 +-- .../PublicApi/PublicApi.approved.txt | 24 ++++----- 16 files changed, 92 insertions(+), 147 deletions(-) delete mode 100644 src/Microsoft.OpenApi/Reader/ParseNodes/ParserHelper.cs delete mode 100644 test/Microsoft.OpenApi.Readers.Tests/ParseNodes/ParserHelperTests.cs diff --git a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiSchema.cs b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiSchema.cs index 954e6b094..a960f2a5a 100644 --- a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiSchema.cs +++ b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiSchema.cs @@ -56,12 +56,12 @@ public interface IOpenApiSchema : IOpenApiDescribedElement, IOpenApiReadOnlyExte /// /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 /// - public decimal? ExclusiveMaximum { get; } + public string? ExclusiveMaximum { get; } /// /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 /// - public decimal? ExclusiveMinimum { get; } + public string? ExclusiveMinimum { get; } /// /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 @@ -84,12 +84,12 @@ public interface IOpenApiSchema : IOpenApiDescribedElement, IOpenApiReadOnlyExte /// /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 /// - public decimal? Maximum { get; } + public string? Maximum { get; } /// /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 /// - public decimal? Minimum { get; } + public string? Minimum { get; } /// /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 diff --git a/src/Microsoft.OpenApi/Models/OpenApiSchema.cs b/src/Microsoft.OpenApi/Models/OpenApiSchema.cs index 6f5014f07..8c1f5d596 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiSchema.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiSchema.cs @@ -44,17 +44,17 @@ public class OpenApiSchema : IOpenApiExtensible, IOpenApiSchema /// public IDictionary? Definitions { get; set; } - private decimal? _exclusiveMaximum; + private string? _exclusiveMaximum; /// - public decimal? ExclusiveMaximum + public string? ExclusiveMaximum { get { - if (_exclusiveMaximum.HasValue) + if (!string.IsNullOrEmpty(_exclusiveMaximum)) { return _exclusiveMaximum; } - if (IsExclusiveMaximum == true && _maximum.HasValue) + if (IsExclusiveMaximum == true && !string.IsNullOrEmpty(_maximum)) { return _maximum; } @@ -73,17 +73,17 @@ public decimal? ExclusiveMaximum /// DO NOT CHANGE THE VISIBILITY OF THIS PROPERTY TO PUBLIC internal bool? IsExclusiveMaximum { get; set; } - private decimal? _exclusiveMinimum; + private string? _exclusiveMinimum; /// - public decimal? ExclusiveMinimum + public string? ExclusiveMinimum { get { - if (_exclusiveMinimum.HasValue) + if (!string.IsNullOrEmpty(_exclusiveMinimum)) { return _exclusiveMinimum; } - if (IsExclusiveMinimum == true && _minimum.HasValue) + if (IsExclusiveMinimum == true && !string.IsNullOrEmpty(_minimum)) { return _minimum; } @@ -114,9 +114,9 @@ public decimal? ExclusiveMinimum /// public string? Description { get; set; } - private decimal? _maximum; + private string? _maximum; /// - public decimal? Maximum + public string? Maximum { get { @@ -132,10 +132,10 @@ public decimal? Maximum } } - private decimal? _minimum; + private string? _minimum; /// - public decimal? Minimum + public string? Minimum { get { @@ -334,38 +334,43 @@ public void SerializeAsV3(IOpenApiWriter writer) SerializeInternal(writer, OpenApiSpecVersion.OpenApi3_0, (writer, element) => element.SerializeAsV3(writer)); } - private static void SerializeBounds(IOpenApiWriter writer, OpenApiSpecVersion version, string propertyName, string exclusivePropertyName, string isExclusivePropertyName, decimal? value, decimal? exclusiveValue, bool? isExclusiveValue) + private static void SerializeBounds(IOpenApiWriter writer, OpenApiSpecVersion version, string propertyName, string exclusivePropertyName, string isExclusivePropertyName, string? value, string? exclusiveValue, bool? isExclusiveValue) { if (version >= OpenApiSpecVersion.OpenApi3_1) { - if (exclusiveValue.HasValue) + if (!string.IsNullOrEmpty(exclusiveValue) && exclusiveValue is not null) { // was explicitly set in the document or object model - writer.WriteProperty(exclusivePropertyName, exclusiveValue.Value); + writer.WritePropertyName(exclusivePropertyName); + writer.WriteRaw(exclusiveValue); } - else if (isExclusiveValue == true && value.HasValue) + else if (isExclusiveValue == true && !string.IsNullOrEmpty(value) && value is not null) { // came from parsing an old document - writer.WriteProperty(exclusivePropertyName, value); + writer.WritePropertyName(exclusivePropertyName); + writer.WriteRaw(value); } - else if (value.HasValue) + else if (!string.IsNullOrEmpty(value) && value is not null) { // was explicitly set in the document or object model - writer.WriteProperty(propertyName, value); + writer.WritePropertyName(propertyName); + writer.WriteRaw(value); } } else { - if (exclusiveValue.HasValue) + if (!string.IsNullOrEmpty(exclusiveValue) && exclusiveValue is not null) { // was explicitly set in a new document being downcast or object model - writer.WriteProperty(propertyName, exclusiveValue.Value); + writer.WritePropertyName(propertyName); + writer.WriteRaw(exclusiveValue); writer.WriteProperty(isExclusivePropertyName, true); } - else if (value.HasValue) + else if (!string.IsNullOrEmpty(value) && value is not null) { // came from parsing an old document, we're just mirroring the information - writer.WriteProperty(propertyName, value); + writer.WritePropertyName(propertyName); + writer.WriteRaw(value); if (isExclusiveValue.HasValue) writer.WriteProperty(isExclusivePropertyName, isExclusiveValue.Value); } diff --git a/src/Microsoft.OpenApi/Models/References/OpenApiSchemaReference.cs b/src/Microsoft.OpenApi/Models/References/OpenApiSchemaReference.cs index e8ce0d907..fb817f56b 100644 --- a/src/Microsoft.OpenApi/Models/References/OpenApiSchemaReference.cs +++ b/src/Microsoft.OpenApi/Models/References/OpenApiSchemaReference.cs @@ -60,9 +60,9 @@ public string? Description /// public IDictionary? Definitions { get => Target?.Definitions; } /// - public decimal? ExclusiveMaximum { get => Target?.ExclusiveMaximum; } + public string? ExclusiveMaximum { get => Target?.ExclusiveMaximum; } /// - public decimal? ExclusiveMinimum { get => Target?.ExclusiveMinimum; } + public string? ExclusiveMinimum { get => Target?.ExclusiveMinimum; } /// public JsonSchemaType? Type { get => Target?.Type; } /// @@ -70,9 +70,9 @@ public string? Description /// public string? Format { get => Target?.Format; } /// - public decimal? Maximum { get => Target?.Maximum; } + public string? Maximum { get => Target?.Maximum; } /// - public decimal? Minimum { get => Target?.Minimum; } + public string? Minimum { get => Target?.Minimum; } /// public int? MaxLength { get => Target?.MaxLength; } /// diff --git a/src/Microsoft.OpenApi/Reader/ParseNodes/ParserHelper.cs b/src/Microsoft.OpenApi/Reader/ParseNodes/ParserHelper.cs deleted file mode 100644 index 030572f68..000000000 --- a/src/Microsoft.OpenApi/Reader/ParseNodes/ParserHelper.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. - -using System; -using System.Globalization; - -namespace Microsoft.OpenApi.Reader.ParseNodes -{ - /// - /// Useful tools to parse data - /// - internal class ParserHelper - { - /// - /// Parses decimal in invariant culture. - /// If the decimal is too big or small, it returns the default value - /// - /// Note: sometimes developers put Double.MaxValue or Long.MaxValue as min/max values for numbers in json schema even if their numbers are not expected to be that big/small. - /// As we have already released the library with Decimal type for Max/Min, let's not introduce the breaking change and just fallback to Decimal.Max / Min. This should satisfy almost every scenario. - /// We can revisit this if somebody really needs to have double or long here. - /// - /// - public static decimal ParseDecimalWithFallbackOnOverflow(string value, decimal defaultValue) - { - try - { - return decimal.Parse(value, NumberStyles.Float, CultureInfo.InvariantCulture); - } - catch (OverflowException) - { - return defaultValue; - } - } - } -} diff --git a/src/Microsoft.OpenApi/Reader/V2/OpenApiHeaderDeserializer.cs b/src/Microsoft.OpenApi/Reader/V2/OpenApiHeaderDeserializer.cs index 4c156c2cc..9e9ff4b97 100644 --- a/src/Microsoft.OpenApi/Reader/V2/OpenApiHeaderDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V2/OpenApiHeaderDeserializer.cs @@ -62,9 +62,9 @@ internal static partial class OpenApiV2Deserializer (o, n, _) => { var max = n.GetScalarValue(); - if (max != null) + if (!string.IsNullOrEmpty(max)) { - GetOrCreateSchema(o).Maximum = ParserHelper.ParseDecimalWithFallbackOnOverflow(max, decimal.MaxValue); + GetOrCreateSchema(o).Maximum = max; } } }, @@ -77,9 +77,9 @@ internal static partial class OpenApiV2Deserializer (o, n, _) => { var min = n.GetScalarValue(); - if (min != null) + if (!string.IsNullOrEmpty(min)) { - GetOrCreateSchema(o).Minimum = ParserHelper.ParseDecimalWithFallbackOnOverflow(min, decimal.MinValue); + GetOrCreateSchema(o).Minimum = min; } } }, diff --git a/src/Microsoft.OpenApi/Reader/V2/OpenApiParameterDeserializer.cs b/src/Microsoft.OpenApi/Reader/V2/OpenApiParameterDeserializer.cs index a074ef242..0ff7773e9 100644 --- a/src/Microsoft.OpenApi/Reader/V2/OpenApiParameterDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V2/OpenApiParameterDeserializer.cs @@ -106,9 +106,9 @@ internal static partial class OpenApiV2Deserializer (o, n, t) => { var min = n.GetScalarValue(); - if (min != null) + if (!string.IsNullOrEmpty(min)) { - GetOrCreateSchema(o).Minimum = ParserHelper.ParseDecimalWithFallbackOnOverflow(min, decimal.MinValue); + GetOrCreateSchema(o).Minimum = min; } } }, @@ -117,9 +117,9 @@ internal static partial class OpenApiV2Deserializer (o, n, t) => { var max = n.GetScalarValue(); - if (max != null) + if (!string.IsNullOrEmpty(max)) { - GetOrCreateSchema(o).Maximum = ParserHelper.ParseDecimalWithFallbackOnOverflow(max, decimal.MaxValue); + GetOrCreateSchema(o).Maximum = max; } } }, diff --git a/src/Microsoft.OpenApi/Reader/V2/OpenApiSchemaDeserializer.cs b/src/Microsoft.OpenApi/Reader/V2/OpenApiSchemaDeserializer.cs index 5597ed1b7..a3fb1153d 100644 --- a/src/Microsoft.OpenApi/Reader/V2/OpenApiSchemaDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V2/OpenApiSchemaDeserializer.cs @@ -41,9 +41,9 @@ internal static partial class OpenApiV2Deserializer (o, n,_) => { var max = n.GetScalarValue(); - if (max != null) + if (!string.IsNullOrEmpty(max)) { - o.Maximum = ParserHelper.ParseDecimalWithFallbackOnOverflow(max, decimal.MaxValue); + o.Maximum = max; } } }, @@ -56,9 +56,9 @@ internal static partial class OpenApiV2Deserializer (o, n, _) => { var min = n.GetScalarValue(); - if (min != null) + if (!string.IsNullOrEmpty(min)) { - o.Minimum = ParserHelper.ParseDecimalWithFallbackOnOverflow(min, decimal.MinValue); + o.Minimum = min; } } }, diff --git a/src/Microsoft.OpenApi/Reader/V3/OpenApiSchemaDeserializer.cs b/src/Microsoft.OpenApi/Reader/V3/OpenApiSchemaDeserializer.cs index 464d6b1b5..85e418b7f 100644 --- a/src/Microsoft.OpenApi/Reader/V3/OpenApiSchemaDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V3/OpenApiSchemaDeserializer.cs @@ -41,9 +41,9 @@ internal static partial class OpenApiV3Deserializer (o, n,_) => { var max = n.GetScalarValue(); - if (max != null) + if (!string.IsNullOrEmpty(max)) { - o.Maximum = ParserHelper.ParseDecimalWithFallbackOnOverflow(max, decimal.MaxValue); + o.Maximum = max; } } }, @@ -52,13 +52,13 @@ internal static partial class OpenApiV3Deserializer (o, n, _) => o.IsExclusiveMaximum = bool.Parse(n.GetScalarValue()) }, { - "minimum", + "minimum", (o, n, _) => { var min = n.GetScalarValue(); - if (min != null) + if (!string.IsNullOrEmpty(min)) { - o.Minimum = ParserHelper.ParseDecimalWithFallbackOnOverflow(min, decimal.MinValue); + o.Minimum = min; } } }, diff --git a/src/Microsoft.OpenApi/Reader/V31/OpenApiSchemaDeserializer.cs b/src/Microsoft.OpenApi/Reader/V31/OpenApiSchemaDeserializer.cs index 717a6e68f..020472c7a 100644 --- a/src/Microsoft.OpenApi/Reader/V31/OpenApiSchemaDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V31/OpenApiSchemaDeserializer.cs @@ -65,30 +65,30 @@ internal static partial class OpenApiV31Deserializer (o, n,_) => { var max = n.GetScalarValue(); - if (max != null) + if (!string.IsNullOrEmpty(max)) { - o.Maximum = ParserHelper.ParseDecimalWithFallbackOnOverflow(max, decimal.MaxValue); + o.Maximum = max; } } }, { "exclusiveMaximum", - (o, n, _) => o.ExclusiveMaximum = ParserHelper.ParseDecimalWithFallbackOnOverflow(n.GetScalarValue(), decimal.MaxValue) + (o, n, _) => o.ExclusiveMaximum = n.GetScalarValue() }, { "minimum", (o, n, _) => { var min = n.GetScalarValue(); - if (min != null) + if (!string.IsNullOrEmpty(min)) { - o.Minimum = ParserHelper.ParseDecimalWithFallbackOnOverflow(min, decimal.MinValue); + o.Minimum = min; } } }, { "exclusiveMinimum", - (o, n, _) => o.ExclusiveMinimum = ParserHelper.ParseDecimalWithFallbackOnOverflow(n.GetScalarValue(), decimal.MaxValue) + (o, n, _) => o.ExclusiveMinimum = n.GetScalarValue() }, { "maxLength", diff --git a/test/Microsoft.OpenApi.Readers.Tests/ParseNodes/ParserHelperTests.cs b/test/Microsoft.OpenApi.Readers.Tests/ParseNodes/ParserHelperTests.cs deleted file mode 100644 index 4e3500d6b..000000000 --- a/test/Microsoft.OpenApi.Readers.Tests/ParseNodes/ParserHelperTests.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. - -using System.Globalization; -using Microsoft.OpenApi.Reader.ParseNodes; -using Xunit; - -namespace Microsoft.OpenApi.Readers.Tests.ParseNodes -{ - [Collection("DefaultSettings")] - public class ParserHelperTests - { - [Fact] - public void ParseDecimalWithFallbackOnOverflow_ReturnsParsedValue() - { - Assert.Equal(23434, ParserHelper.ParseDecimalWithFallbackOnOverflow("23434", 10)); - } - - [Fact] - public void ParseDecimalWithFallbackOnOverflow_Overflows_ReturnsFallback() - { - Assert.Equal(10, ParserHelper.ParseDecimalWithFallbackOnOverflow(double.MaxValue.ToString(CultureInfo.InvariantCulture), 10)); - } - } -} diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs index f76e3311c..6bf41959c 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs @@ -62,8 +62,8 @@ public void ParseDocumentWithDifferentCultureShouldSucceed(string culture) var expectedPropertySchema = new OpenApiSchema() { Type = JsonSchemaType.Number, - Minimum = (decimal)100.54, - ExclusiveMaximum = (decimal)60000000.35, + Minimum = "100.54", + ExclusiveMaximum = "60000000.35", }; Assert.Equivalent(expectedPropertySchema, samplePropertySchema); diff --git a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiSchemaTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiSchemaTests.cs index f7b219f97..838ecbff2 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiSchemaTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiSchemaTests.cs @@ -239,22 +239,22 @@ public async Task ParseAdvancedV31SchemaShouldSucceed() ["six"] = new OpenApiSchema() { Description = "exclusiveMinimum true", - ExclusiveMinimum = 10 + ExclusiveMinimum = "10" }, ["seven"] = new OpenApiSchema() { Description = "exclusiveMinimum false", - Minimum = 10 + Minimum = "10" }, ["eight"] = new OpenApiSchema() { Description = "exclusiveMaximum true", - ExclusiveMaximum = 20 + ExclusiveMaximum = "20" }, ["nine"] = new OpenApiSchema() { Description = "exclusiveMaximum false", - Maximum = 20 + Maximum = "20" }, ["ten"] = new OpenApiSchema() { diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs index cdc80e603..0ea179f56 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs @@ -250,8 +250,8 @@ public async Task ParseBasicSchemaWithReferenceShouldSucceed() ["code"] = new OpenApiSchema() { Type = JsonSchemaType.Integer, - Minimum = 100, - Maximum = 600 + Minimum = "100", + Maximum = "600" }, ["message"] = new OpenApiSchema() { @@ -369,7 +369,7 @@ public async Task ParseAdvancedSchemaWithReferenceShouldSucceed() Format = "int32", Description = "the size of the pack the dog is from", Default = 0, - Minimum = 0 + Minimum = "0" } } } diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs index 33730484b..d7315d5ab 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs @@ -51,8 +51,8 @@ public class OpenApiOperationTests Schema = new OpenApiSchema() { Type = JsonSchemaType.Number, - Minimum = 5, - Maximum = 10 + Minimum = "5", + Maximum = "10" } } } @@ -69,8 +69,8 @@ public class OpenApiOperationTests Schema = new OpenApiSchema() { Type = JsonSchemaType.Number, - Minimum = 5, - Maximum = 10 + Minimum = "5", + Maximum = "10" } } } @@ -125,8 +125,8 @@ public class OpenApiOperationTests Schema = new OpenApiSchema() { Type = JsonSchemaType.Number, - Minimum = 5, - Maximum = 10 + Minimum = "5", + Maximum = "10" } } } @@ -143,8 +143,8 @@ public class OpenApiOperationTests Schema = new OpenApiSchema() { Type = JsonSchemaType.Number, - Minimum = 5, - Maximum = 10 + Minimum = "5", + Maximum = "10" } } } diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs index 9fc3dcebb..bc0056c5a 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs @@ -29,8 +29,8 @@ public class OpenApiSchemaTests { Title = "title1", MultipleOf = 3, - Maximum = 42, - ExclusiveMinimum = 10, + Maximum = "42", + ExclusiveMinimum = "10", Default = 15, Type = JsonSchemaType.Integer | JsonSchemaType.Null, @@ -146,8 +146,8 @@ public class OpenApiSchemaTests { Title = "title1", MultipleOf = 3, - Maximum = 42, - ExclusiveMinimum = 10, + Maximum = "42", + ExclusiveMinimum = "10", Default = 15, Type = JsonSchemaType.Integer | JsonSchemaType.Null, diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index 755a9e17e..140cfd46c 100644 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -429,8 +429,8 @@ namespace Microsoft.OpenApi.Models.Interfaces System.Collections.Generic.IList? Enum { get; } System.Text.Json.Nodes.JsonNode? Example { get; } System.Collections.Generic.IList? Examples { get; } - decimal? ExclusiveMaximum { get; } - decimal? ExclusiveMinimum { get; } + string? ExclusiveMaximum { get; } + string? ExclusiveMinimum { get; } Microsoft.OpenApi.Models.OpenApiExternalDocs? ExternalDocs { get; } string? Format { get; } string? Id { get; } @@ -438,11 +438,11 @@ namespace Microsoft.OpenApi.Models.Interfaces int? MaxItems { get; } int? MaxLength { get; } int? MaxProperties { get; } - decimal? Maximum { get; } + string? Maximum { get; } int? MinItems { get; } int? MinLength { get; } int? MinProperties { get; } - decimal? Minimum { get; } + string? Minimum { get; } decimal? MultipleOf { get; } Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema? Not { get; } System.Collections.Generic.IList? OneOf { get; } @@ -1031,8 +1031,8 @@ namespace Microsoft.OpenApi.Models public System.Collections.Generic.IList? Enum { get; set; } public System.Text.Json.Nodes.JsonNode? Example { get; set; } public System.Collections.Generic.IList? Examples { get; set; } - public decimal? ExclusiveMaximum { get; set; } - public decimal? ExclusiveMinimum { get; set; } + public string? ExclusiveMaximum { get; set; } + public string? ExclusiveMinimum { get; set; } public System.Collections.Generic.IDictionary? Extensions { get; set; } public Microsoft.OpenApi.Models.OpenApiExternalDocs? ExternalDocs { get; set; } public string? Format { get; set; } @@ -1041,11 +1041,11 @@ namespace Microsoft.OpenApi.Models public int? MaxItems { get; set; } public int? MaxLength { get; set; } public int? MaxProperties { get; set; } - public decimal? Maximum { get; set; } + public string? Maximum { get; set; } public int? MinItems { get; set; } public int? MinLength { get; set; } public int? MinProperties { get; set; } - public decimal? Minimum { get; set; } + public string? Minimum { get; set; } public decimal? MultipleOf { get; set; } public Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema? Not { get; set; } public System.Collections.Generic.IList? OneOf { get; set; } @@ -1363,8 +1363,8 @@ namespace Microsoft.OpenApi.Models.References public System.Collections.Generic.IList? Enum { get; } public System.Text.Json.Nodes.JsonNode? Example { get; } public System.Collections.Generic.IList? Examples { get; } - public decimal? ExclusiveMaximum { get; } - public decimal? ExclusiveMinimum { get; } + public string? ExclusiveMaximum { get; } + public string? ExclusiveMinimum { get; } public System.Collections.Generic.IDictionary? Extensions { get; } public Microsoft.OpenApi.Models.OpenApiExternalDocs? ExternalDocs { get; } public string? Format { get; } @@ -1373,11 +1373,11 @@ namespace Microsoft.OpenApi.Models.References public int? MaxItems { get; } public int? MaxLength { get; } public int? MaxProperties { get; } - public decimal? Maximum { get; } + public string? Maximum { get; } public int? MinItems { get; } public int? MinLength { get; } public int? MinProperties { get; } - public decimal? Minimum { get; } + public string? Minimum { get; } public decimal? MultipleOf { get; } public Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema? Not { get; } public System.Collections.Generic.IList? OneOf { get; } From 1d593963abf3fb1620be3e35bc647b40791b6a5d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 8 Apr 2025 22:00:50 +0000 Subject: [PATCH 054/984] chore(deps): bump Microsoft.Extensions.Logging.Abstractions Bumps [Microsoft.Extensions.Logging.Abstractions](https://github.com/dotnet/runtime) from 9.0.3 to 9.0.4. - [Release notes](https://github.com/dotnet/runtime/releases) - [Commits](https://github.com/dotnet/runtime/compare/v9.0.3...v9.0.4) --- updated-dependencies: - dependency-name: Microsoft.Extensions.Logging.Abstractions dependency-version: 9.0.4 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index 5bc72d2c5..437fbef5d 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -29,7 +29,7 @@ - + From 8a7c612a33644637a76454e52981e7f574ef5839 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 8 Apr 2025 22:01:38 +0000 Subject: [PATCH 055/984] chore(deps): bump Microsoft.Windows.Compatibility from 9.0.3 to 9.0.4 Bumps [Microsoft.Windows.Compatibility](https://github.com/dotnet/windowsdesktop) from 9.0.3 to 9.0.4. - [Release notes](https://github.com/dotnet/windowsdesktop/releases) - [Commits](https://github.com/dotnet/windowsdesktop/compare/v9.0.3...v9.0.4) --- updated-dependencies: - dependency-name: Microsoft.Windows.Compatibility dependency-version: 9.0.4 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .../Microsoft.OpenApi.Workbench.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj index 5cfd3cfe4..2bac12dc6 100644 --- a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj +++ b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj @@ -13,7 +13,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - + From 55753d590985abaa9405f24eb02f54085928176a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 8 Apr 2025 22:06:31 +0000 Subject: [PATCH 056/984] chore(deps): bump System.Text.Json from 9.0.3 to 9.0.4 Bumps [System.Text.Json](https://github.com/dotnet/runtime) from 9.0.3 to 9.0.4. - [Release notes](https://github.com/dotnet/runtime/releases) - [Commits](https://github.com/dotnet/runtime/compare/v9.0.3...v9.0.4) --- updated-dependencies: - dependency-name: System.Text.Json dependency-version: 9.0.4 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 9355e19da..cf5736be0 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -14,7 +14,7 @@ - + From 36043829d29340a47fc93c6477a38ea93e59ef57 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Wed, 9 Apr 2025 12:29:41 +0300 Subject: [PATCH 057/984] feat: Remove default collection initialization for perf reasons (#2284) * feat: use lazy get for collection initialization to reduce resource allocation * chore: use Lazy pattern; preserve null values * chore: replicate for collections in other components * chore: remove unnecessary usings * fix: revert lazy initialization; remove collection initialization * chore: initialize collections to prevent NREs * chore: fix failing tests * chore: revert changes * chore: remove default collection initialization across all models; clean up and fix tests * chore: clean up code; initialize collections where applicable * chore: more cleanup * chore: move assignment within the condition * chore: replace interface with concrete type * chore: simplify collection initialization * Update src/Microsoft.OpenApi/Models/OpenApiPathItem.cs Co-authored-by: Vincent Biret * chore: implement PR feedback * chore: reverts casing change --------- Co-authored-by: Vincent Biret --- README.md | 2 +- .../Extensions/OpenApiExtensibleExtensions.cs | 2 +- .../Extensions/StringExtensions.cs | 2 +- .../Formatters/PowerShellFormatter.cs | 10 +- src/Microsoft.OpenApi.Hidi/StatsVisitor.cs | 2 +- .../StatsVisitor.cs | 2 +- .../Extensions/OpenApiExtensibleExtensions.cs | 7 +- .../Extensions/OpenApiServerExtensions.cs | 2 +- .../Interfaces/IMetadataContainer.cs | 2 +- .../Interfaces/IOpenApiExtensible.cs | 2 +- .../Interfaces/IOpenApiReadOnlyExtensible.cs | 2 +- .../Models/Interfaces/IOpenApiHeader.cs | 4 +- .../Models/Interfaces/IOpenApiLink.cs | 2 +- .../Models/Interfaces/IOpenApiParameter.cs | 4 +- .../Models/Interfaces/IOpenApiPathItem.cs | 6 +- .../Models/Interfaces/IOpenApiRequestBody.cs | 2 +- .../Models/Interfaces/IOpenApiResponse.cs | 6 +- .../Models/Interfaces/IOpenApiSchema.cs | 26 +- .../Models/OpenApiCallback.cs | 5 +- .../Models/OpenApiComponents.cs | 27 +- .../Models/OpenApiContact.cs | 2 +- .../Models/OpenApiDiscriminator.cs | 4 +- .../Models/OpenApiDocument.cs | 43 +- .../Models/OpenApiEncoding.cs | 4 +- .../Models/OpenApiExample.cs | 4 +- .../Models/OpenApiExtensibleDictionary.cs | 4 +- .../Models/OpenApiExternalDocs.cs | 2 +- src/Microsoft.OpenApi/Models/OpenApiHeader.cs | 6 +- src/Microsoft.OpenApi/Models/OpenApiInfo.cs | 2 +- .../Models/OpenApiLicense.cs | 2 +- src/Microsoft.OpenApi/Models/OpenApiLink.cs | 6 +- .../Models/OpenApiMediaType.cs | 8 +- .../Models/OpenApiOAuthFlow.cs | 4 +- .../Models/OpenApiOAuthFlows.cs | 2 +- .../Models/OpenApiOperation.cs | 24 +- .../Models/OpenApiParameter.cs | 6 +- .../Models/OpenApiPathItem.cs | 21 +- .../Models/OpenApiRequestBody.cs | 6 +- .../Models/OpenApiResponse.cs | 12 +- src/Microsoft.OpenApi/Models/OpenApiSchema.cs | 66 +-- .../Models/OpenApiSecurityRequirement.cs | 2 +- .../Models/OpenApiSecurityScheme.cs | 4 +- src/Microsoft.OpenApi/Models/OpenApiServer.cs | 5 +- .../Models/OpenApiServerVariable.cs | 2 +- src/Microsoft.OpenApi/Models/OpenApiTag.cs | 4 +- src/Microsoft.OpenApi/Models/OpenApiXml.cs | 2 +- .../References/OpenApiCallbackReference.cs | 2 +- .../References/OpenApiExampleReference.cs | 2 +- .../References/OpenApiHeaderReference.cs | 6 +- .../Models/References/OpenApiLinkReference.cs | 4 +- .../References/OpenApiParameterReference.cs | 6 +- .../References/OpenApiPathItemReference.cs | 8 +- .../References/OpenApiRequestBodyReference.cs | 4 +- .../References/OpenApiResponseReference.cs | 8 +- .../References/OpenApiSchemaReference.cs | 28 +- .../OpenApiSecuritySchemeReference.cs | 2 +- .../Models/References/OpenApiTagReference.cs | 2 +- .../Reader/OpenApiDiagnostic.cs | 4 +- .../ParseNodes/AnyListFieldMapParameter.cs | 8 +- .../ParseNodes/AnyMapFieldMapParameter.cs | 4 +- .../Reader/ParseNodes/MapNode.cs | 4 +- .../Reader/ParseNodes/ParseNode.cs | 2 +- .../Reader/ParseNodes/PropertyNode.cs | 4 +- .../Reader/V2/OpenApiDocumentDeserializer.cs | 10 +- .../Reader/V2/OpenApiOperationDeserializer.cs | 8 +- .../Reader/V2/OpenApiResponseDeserializer.cs | 7 +- .../Reader/V31/OpenApiSchemaDeserializer.cs | 4 +- .../Reader/V31/OpenApiV31VersionService.cs | 2 +- .../Services/CopyReferences.cs | 50 ++- .../Services/OpenApiFilterService.cs | 40 +- .../Services/OpenApiUrlTreeNode.cs | 6 +- .../Services/OpenApiVisitorBase.cs | 30 +- .../Services/OpenApiWalker.cs | 38 +- .../Services/OperationSearch.cs | 4 +- .../Services/SearchResult.cs | 2 +- .../Validations/OpenApiValidator.cs | 22 +- .../Validations/Rules/OpenApiContactRules.cs | 9 +- .../Rules/OpenApiExtensionRules.cs | 6 +- .../Rules/OpenApiNonDefaultRules.cs | 2 +- .../Validations/Rules/OpenApiSchemaRules.cs | 4 +- .../Validations/Rules/OpenApiServerRules.cs | 6 +- .../Validations/Rules/RuleHelpers.cs | 8 +- .../Validations/ValidationRuleSet.cs | 22 +- .../Writers/OpenApiWriterAnyExtensions.cs | 2 +- .../Writers/OpenApiWriterExtensions.cs | 22 +- .../Formatters/PowerShellFormatterTests.cs | 30 +- .../Services/OpenApiFilterServiceTests.cs | 14 +- .../Services/OpenApiServiceTests.cs | 2 +- .../UtilityFiles/OpenApiDocumentMock.cs | 150 ++++--- .../TryLoadReferenceV2Tests.cs | 4 +- .../V2Tests/OpenApiDocumentTests.cs | 24 +- .../V2Tests/OpenApiHeaderTests.cs | 4 +- .../V2Tests/OpenApiOperationTests.cs | 24 +- .../V2Tests/OpenApiParameterTests.cs | 10 +- .../V2Tests/OpenApiPathItemTests.cs | 28 +- .../V2Tests/OpenApiSchemaTests.cs | 15 +- .../V2Tests/OpenApiSecuritySchemeTests.cs | 12 +- .../V31Tests/OpenApiDocumentTests.cs | 88 ++-- .../V31Tests/OpenApiSchemaTests.cs | 10 +- .../V3Tests/OpenApiCallbackTests.cs | 32 +- .../V3Tests/OpenApiDiscriminatorTests.cs | 5 +- .../V3Tests/OpenApiDocumentTests.cs | 142 +++---- .../V3Tests/OpenApiEncodingTests.cs | 4 +- .../V3Tests/OpenApiInfoTests.cs | 11 +- .../V3Tests/OpenApiMediaTypeTests.cs | 4 +- .../V3Tests/OpenApiOperationTests.cs | 8 +- .../V3Tests/OpenApiParameterTests.cs | 16 +- .../V3Tests/OpenApiSchemaTests.cs | 69 ++-- .../V3Tests/OpenApiSecuritySchemeTests.cs | 2 +- .../Models/OpenApiCallbackTests.cs | 14 +- .../Models/OpenApiComponentsTests.cs | 40 +- .../Models/OpenApiContactTests.cs | 2 +- .../Models/OpenApiDocumentTests.cs | 238 ++++++----- .../Models/OpenApiInfoTests.cs | 4 +- .../Models/OpenApiLicenseTests.cs | 2 +- .../Models/OpenApiLinkTests.cs | 12 +- .../Models/OpenApiMediaTypeTests.cs | 5 +- .../Models/OpenApiOperationTests.cs | 40 +- .../Models/OpenApiParameterTests.cs | 15 +- .../Models/OpenApiRequestBodyTests.cs | 5 +- .../Models/OpenApiResponseTests.cs | 21 +- .../Models/OpenApiSchemaTests.cs | 44 +- .../Models/OpenApiTagTests.cs | 2 +- .../Models/OpenApiXmlTests.cs | 2 +- .../References/OpenApiHeaderReferenceTests.cs | 4 +- .../PublicApi/PublicApi.approved.txt | 388 +++++++++--------- .../Services/OpenApiUrlTreeNodeTests.cs | 14 +- .../Services/OpenApiValidatorTests.cs | 21 +- .../OpenApiHeaderValidationTests.cs | 2 +- .../OpenApiMediaTypeValidationTests.cs | 5 +- .../OpenApiOAuthFlowValidationTests.cs | 6 +- .../OpenApiParameterValidationTests.cs | 4 +- .../OpenApiReferenceValidationTests.cs | 14 +- .../OpenApiSchemaValidationTests.cs | 21 +- .../Validations/OpenApiTagValidationTests.cs | 5 +- .../Validations/ValidationRuleSetTests.cs | 46 +-- .../Visitors/InheritanceTests.cs | 52 +-- .../Walkers/WalkerLocationTests.cs | 34 +- .../Workspaces/OpenApiReferencableTests.cs | 75 ++-- .../Workspaces/OpenApiWorkspaceTests.cs | 12 +- .../Writers/OpenApiJsonWriterTests.cs | 35 +- .../Writers/OpenApiYamlWriterTests.cs | 17 +- 142 files changed, 1357 insertions(+), 1318 deletions(-) diff --git a/README.md b/README.md index a18c00723..f903038cd 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ var document = new OpenApiDocument { ["/pets"] = new OpenApiPathItem { - Operations = new Dictionary + Operations = new() { [HttpMethod.Get] = new OpenApiOperation { diff --git a/src/Microsoft.OpenApi.Hidi/Extensions/OpenApiExtensibleExtensions.cs b/src/Microsoft.OpenApi.Hidi/Extensions/OpenApiExtensibleExtensions.cs index f4b4f77c5..368b67e8c 100644 --- a/src/Microsoft.OpenApi.Hidi/Extensions/OpenApiExtensibleExtensions.cs +++ b/src/Microsoft.OpenApi.Hidi/Extensions/OpenApiExtensibleExtensions.cs @@ -13,7 +13,7 @@ internal static class OpenApiExtensibleExtensions /// A dictionary of . /// The key corresponding to the . /// A value matching the provided extensionKey. Return null when extensionKey is not found. - internal static string GetExtension(this IDictionary extensions, string extensionKey) + internal static string GetExtension(this Dictionary extensions, string extensionKey) { if (extensions.TryGetValue(extensionKey, out var value) && value is OpenApiAny { Node: JsonValue castValue } && castValue.TryGetValue(out var stringValue)) { diff --git a/src/Microsoft.OpenApi.Hidi/Extensions/StringExtensions.cs b/src/Microsoft.OpenApi.Hidi/Extensions/StringExtensions.cs index 3d6362084..bd05e9649 100644 --- a/src/Microsoft.OpenApi.Hidi/Extensions/StringExtensions.cs +++ b/src/Microsoft.OpenApi.Hidi/Extensions/StringExtensions.cs @@ -34,7 +34,7 @@ public static bool IsEquals(this string? target, string? searchValue, StringComp /// The target string to split by char. /// The char separator. /// An containing substrings. - public static IList SplitByChar(this string target, char separator) + public static List SplitByChar(this string target, char separator) { if (string.IsNullOrWhiteSpace(target)) { diff --git a/src/Microsoft.OpenApi.Hidi/Formatters/PowerShellFormatter.cs b/src/Microsoft.OpenApi.Hidi/Formatters/PowerShellFormatter.cs index b46e0b2a6..a07888a99 100644 --- a/src/Microsoft.OpenApi.Hidi/Formatters/PowerShellFormatter.cs +++ b/src/Microsoft.OpenApi.Hidi/Formatters/PowerShellFormatter.cs @@ -77,7 +77,7 @@ public override void Visit(OpenApiOperation operation) // Order matters. Resolve operationId. operationId = RemoveHashSuffix(operationId); if (operationTypeExtension.IsEquals("action") || operationTypeExtension.IsEquals("function")) - operationId = RemoveKeyTypeSegment(operationId, operation.Parameters ?? new List()); + operationId = RemoveKeyTypeSegment(operationId, operation.Parameters ?? []); operationId = SingularizeAndDeduplicateOperationId(operationId.SplitByChar('.')); operationId = ResolveODataCastOperationId(operationId); operationId = ResolveByRefOperationId(operationId); @@ -119,7 +119,7 @@ private static string ResolveODataCastOperationId(string operationId) return match.Success ? $"{match.Groups[1]}{match.Groups[2]}" : operationId; } - private static string SingularizeAndDeduplicateOperationId(IList operationIdSegments) + private static string SingularizeAndDeduplicateOperationId(List operationIdSegments) { var segmentsCount = operationIdSegments.Count; var lastSegmentIndex = segmentsCount - 1; @@ -145,7 +145,7 @@ private static string RemoveHashSuffix(string operationId) return s_hashSuffixRegex.Match(operationId).Value; } - private static string RemoveKeyTypeSegment(string operationId, IList parameters) + private static string RemoveKeyTypeSegment(string operationId, List parameters) { var segments = operationId.SplitByChar('.'); foreach (var parameter in parameters) @@ -159,9 +159,9 @@ private static string RemoveKeyTypeSegment(string operationId, IList parameters) + private static void ResolveFunctionParameters(List parameters) { - foreach (var parameter in parameters.OfType().Where(static p => p.Content?.Any() ?? false)) + foreach (var parameter in parameters.OfType().Where(static p => p.Content?.Count > 0)) { // Replace content with a schema object of type array // for structured or collection-valued function parameters diff --git a/src/Microsoft.OpenApi.Hidi/StatsVisitor.cs b/src/Microsoft.OpenApi.Hidi/StatsVisitor.cs index d157a6c42..0f5a9faf4 100644 --- a/src/Microsoft.OpenApi.Hidi/StatsVisitor.cs +++ b/src/Microsoft.OpenApi.Hidi/StatsVisitor.cs @@ -27,7 +27,7 @@ public override void Visit(IOpenApiSchema schema) public int HeaderCount { get; set; } - public override void Visit(IDictionary headers) + public override void Visit(Dictionary headers) { HeaderCount++; } diff --git a/src/Microsoft.OpenApi.Workbench/StatsVisitor.cs b/src/Microsoft.OpenApi.Workbench/StatsVisitor.cs index 85dc824a4..cdcdb6af9 100644 --- a/src/Microsoft.OpenApi.Workbench/StatsVisitor.cs +++ b/src/Microsoft.OpenApi.Workbench/StatsVisitor.cs @@ -27,7 +27,7 @@ public override void Visit(IOpenApiSchema schema) public int HeaderCount { get; set; } - public override void Visit(IDictionary headers) + public override void Visit(Dictionary headers) { HeaderCount++; } diff --git a/src/Microsoft.OpenApi/Extensions/OpenApiExtensibleExtensions.cs b/src/Microsoft.OpenApi/Extensions/OpenApiExtensibleExtensions.cs index 01fc02020..bea3597a6 100644 --- a/src/Microsoft.OpenApi/Extensions/OpenApiExtensibleExtensions.cs +++ b/src/Microsoft.OpenApi/Extensions/OpenApiExtensibleExtensions.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. using System; +using System.Collections.Generic; using Microsoft.OpenApi.Exceptions; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; @@ -32,10 +33,8 @@ public static void AddExtension(this T element, string name, IOpenApiExtensio throw new OpenApiException(string.Format(SRResource.ExtensionFieldNameMustBeginWithXDash, name)); } - if (element.Extensions is not null) - { - element.Extensions[name] = Utils.CheckArgumentNull(any); - } + element.Extensions ??= []; + element.Extensions[name] = Utils.CheckArgumentNull(any); } } } diff --git a/src/Microsoft.OpenApi/Extensions/OpenApiServerExtensions.cs b/src/Microsoft.OpenApi/Extensions/OpenApiServerExtensions.cs index 5276876ce..befeddaa9 100644 --- a/src/Microsoft.OpenApi/Extensions/OpenApiServerExtensions.cs +++ b/src/Microsoft.OpenApi/Extensions/OpenApiServerExtensions.cs @@ -21,7 +21,7 @@ public static class OpenApiServerExtensions /// 1. A substitution has no valid value in both the supplied dictionary and the default /// 2. A substitution's value is not available in the enum provided /// - public static string? ReplaceServerUrlVariables(this OpenApiServer server, IDictionary? values = null) + public static string? ReplaceServerUrlVariables(this OpenApiServer server, Dictionary? values = null) { var parsedUrl = server.Url; if (server.Variables is not null && parsedUrl is not null) diff --git a/src/Microsoft.OpenApi/Interfaces/IMetadataContainer.cs b/src/Microsoft.OpenApi/Interfaces/IMetadataContainer.cs index 2ae2248de..d97635c9c 100644 --- a/src/Microsoft.OpenApi/Interfaces/IMetadataContainer.cs +++ b/src/Microsoft.OpenApi/Interfaces/IMetadataContainer.cs @@ -14,6 +14,6 @@ public interface IMetadataContainer /// /// A collection of properties associated with the current OpenAPI element. /// - IDictionary? Metadata { get; set; } + Dictionary? Metadata { get; set; } } } diff --git a/src/Microsoft.OpenApi/Interfaces/IOpenApiExtensible.cs b/src/Microsoft.OpenApi/Interfaces/IOpenApiExtensible.cs index fabd1a177..be7796a24 100644 --- a/src/Microsoft.OpenApi/Interfaces/IOpenApiExtensible.cs +++ b/src/Microsoft.OpenApi/Interfaces/IOpenApiExtensible.cs @@ -13,6 +13,6 @@ public interface IOpenApiExtensible : IOpenApiElement /// /// Specification extensions. /// - IDictionary? Extensions { get; set; } + Dictionary? Extensions { get; set; } } } diff --git a/src/Microsoft.OpenApi/Interfaces/IOpenApiReadOnlyExtensible.cs b/src/Microsoft.OpenApi/Interfaces/IOpenApiReadOnlyExtensible.cs index db451d843..fc3d19cfa 100644 --- a/src/Microsoft.OpenApi/Interfaces/IOpenApiReadOnlyExtensible.cs +++ b/src/Microsoft.OpenApi/Interfaces/IOpenApiReadOnlyExtensible.cs @@ -10,6 +10,6 @@ public interface IOpenApiReadOnlyExtensible /// /// Specification extensions. /// - IDictionary? Extensions { get; } + Dictionary? Extensions { get; } } diff --git a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiHeader.cs b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiHeader.cs index c6550caa6..fc580847c 100644 --- a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiHeader.cs +++ b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiHeader.cs @@ -55,11 +55,11 @@ public interface IOpenApiHeader : IOpenApiDescribedElement, IOpenApiReadOnlyExte /// /// Examples of the media type. /// - public IDictionary? Examples { get; } + public Dictionary? Examples { get; } /// /// A map containing the representations for the header. /// - public IDictionary? Content { get; } + public Dictionary? Content { get; } } diff --git a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiLink.cs b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiLink.cs index 6fc9abeb6..8a263f59d 100644 --- a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiLink.cs +++ b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiLink.cs @@ -24,7 +24,7 @@ public interface IOpenApiLink : IOpenApiDescribedElement, IOpenApiReadOnlyExtens /// /// A map representing parameters to pass to an operation as specified with operationId or identified via operationRef. /// - public IDictionary? Parameters { get; } + public Dictionary? Parameters { get; } /// /// A literal value or {expression} to use as a request body when calling the target operation. diff --git a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiParameter.cs b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiParameter.cs index 63c3a860f..8340fb698 100644 --- a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiParameter.cs +++ b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiParameter.cs @@ -81,7 +81,7 @@ public interface IOpenApiParameter : IOpenApiDescribedElement, IOpenApiReadOnlyE /// Furthermore, if referencing a schema which contains an example, /// the examples value SHALL override the example provided by the schema. /// - public IDictionary? Examples { get; } + public Dictionary? Examples { get; } /// /// Example of the media type. The example SHOULD match the specified schema and encoding properties @@ -102,5 +102,5 @@ public interface IOpenApiParameter : IOpenApiDescribedElement, IOpenApiReadOnlyE /// When example or examples are provided in conjunction with the schema object, /// the example MUST follow the prescribed serialization strategy for the parameter. /// - public IDictionary? Content { get; } + public Dictionary? Content { get; } } diff --git a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiPathItem.cs b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiPathItem.cs index f4348154e..ca105bd76 100644 --- a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiPathItem.cs +++ b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiPathItem.cs @@ -14,16 +14,16 @@ public interface IOpenApiPathItem : IOpenApiDescribedElement, IOpenApiSummarized /// /// Gets the definition of operations on this path. /// - public IDictionary? Operations { get; } + public Dictionary? Operations { get; } /// /// An alternative server array to service all operations in this path. /// - public IList? Servers { get; } + public List? Servers { get; } /// /// A list of parameters that are applicable for all the operations described under this path. /// These parameters can be overridden at the operation level, but cannot be removed there. /// - public IList? Parameters { get; } + public List? Parameters { get; } } diff --git a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiRequestBody.cs b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiRequestBody.cs index b9c8304df..966361bfa 100644 --- a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiRequestBody.cs +++ b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiRequestBody.cs @@ -19,7 +19,7 @@ public interface IOpenApiRequestBody : IOpenApiDescribedElement, IOpenApiReadOnl /// REQUIRED. The content of the request body. The key is a media type or media type range and the value describes it. /// For requests that match multiple keys, only the most specific key is applicable. e.g. text/plain overrides text/* /// - public IDictionary? Content { get; } + public Dictionary? Content { get; } /// /// Converts the request body to a body parameter in preparation for a v2 serialization. /// diff --git a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiResponse.cs b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiResponse.cs index 379526e0a..0ad10c1e9 100644 --- a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiResponse.cs +++ b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiResponse.cs @@ -12,18 +12,18 @@ public interface IOpenApiResponse : IOpenApiDescribedElement, IOpenApiReadOnlyEx /// /// Maps a header name to its definition. /// - public IDictionary? Headers { get; } + public Dictionary? Headers { get; } /// /// A map containing descriptions of potential response payloads. /// The key is a media type or media type range and the value describes it. /// - public IDictionary? Content { get; } + public Dictionary? Content { get; } /// /// A map of operations links that can be followed from the response. /// The key of the map is a short name for the link, /// following the naming constraints of the names for Component Objects. /// - public IDictionary? Links { get; } + public Dictionary? Links { get; } } diff --git a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiSchema.cs b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiSchema.cs index a960f2a5a..ea6f4edd3 100644 --- a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiSchema.cs +++ b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiSchema.cs @@ -35,7 +35,7 @@ public interface IOpenApiSchema : IOpenApiDescribedElement, IOpenApiReadOnlyExte /// /// $vocabulary- used in meta-schemas to identify the vocabularies available for use in schemas described by that meta-schema. /// - public IDictionary? Vocabulary { get; } + public Dictionary? Vocabulary { get; } /// /// $dynamicRef - an applicator that allows for deferring the full resolution until runtime, at which point it is resolved each time it is encountered while evaluating an instance @@ -51,7 +51,7 @@ public interface IOpenApiSchema : IOpenApiDescribedElement, IOpenApiReadOnlyExte /// $defs - reserves a location for schema authors to inline re-usable JSON Schemas into a more general schema. /// The keyword does not directly affect the validation result /// - public IDictionary? Definitions { get; } + public Dictionary? Definitions { get; } /// /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 @@ -144,19 +144,19 @@ public interface IOpenApiSchema : IOpenApiDescribedElement, IOpenApiReadOnlyExte /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 /// Inline or referenced schema MUST be of a Schema Object and not a standard JSON Schema. /// - public IList? AllOf { get; } + public List? AllOf { get; } /// /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 /// Inline or referenced schema MUST be of a Schema Object and not a standard JSON Schema. /// - public IList? OneOf { get; } + public List? OneOf { get; } /// /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 /// Inline or referenced schema MUST be of a Schema Object and not a standard JSON Schema. /// - public IList? AnyOf { get; } + public List? AnyOf { get; } /// /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 @@ -167,7 +167,7 @@ public interface IOpenApiSchema : IOpenApiDescribedElement, IOpenApiReadOnlyExte /// /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 /// - public ISet? Required { get; } + public HashSet? Required { get; } /// /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 @@ -195,7 +195,7 @@ public interface IOpenApiSchema : IOpenApiDescribedElement, IOpenApiReadOnlyExte /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 /// Property definitions MUST be a Schema Object and not a standard JSON Schema (inline or referenced). /// - public IDictionary? Properties { get; } + public Dictionary? Properties { get; } /// /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 @@ -204,7 +204,7 @@ public interface IOpenApiSchema : IOpenApiDescribedElement, IOpenApiReadOnlyExte /// egular expression dialect. Each property value of this object MUST be an object, and each object MUST /// be a valid Schema Object not a standard JSON Schema. /// - public IDictionary? PatternProperties { get; } + public Dictionary? PatternProperties { get; } /// /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 @@ -246,12 +246,12 @@ public interface IOpenApiSchema : IOpenApiDescribedElement, IOpenApiReadOnlyExte /// To represent examples that cannot be naturally represented in JSON or YAML, /// a list of values can be used to contain the examples with escaping where necessary. /// - public IList? Examples { get; } + public List? Examples { get; } /// /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 /// - public IList? Enum { get; } + public List? Enum { get; } /// /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 @@ -278,16 +278,16 @@ public interface IOpenApiSchema : IOpenApiDescribedElement, IOpenApiReadOnlyExte /// /// This object stores any unrecognized keywords found in the schema. /// - public IDictionary? UnrecognizedKeywords { get; } + public Dictionary? UnrecognizedKeywords { get; } /// /// Any annotation to attach to the schema to be used by the application. /// Annotations are NOT (de)serialized with the schema and can be used for custom properties. /// - public IDictionary? Annotations { get; } + public Dictionary? Annotations { get; } /// /// Follow JSON Schema definition:https://json-schema.org/draft/2020-12/json-schema-validation#section-6.5.4 /// - public IDictionary>? DependentRequired { get; } + public Dictionary>? DependentRequired { get; } } diff --git a/src/Microsoft.OpenApi/Models/OpenApiCallback.cs b/src/Microsoft.OpenApi/Models/OpenApiCallback.cs index 435d9155e..8bd90ed7f 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiCallback.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiCallback.cs @@ -13,17 +13,16 @@ namespace Microsoft.OpenApi.Models /// /// Callback Object: A map of possible out-of band callbacks related to the parent operation. /// - public class OpenApiCallback : IOpenApiReferenceable, IOpenApiExtensible, IOpenApiCallback + public class OpenApiCallback : IOpenApiExtensible, IOpenApiCallback { /// public Dictionary? PathItems { get; set; } - = []; /// /// This object MAY be extended with Specification Extensions. /// - public IDictionary? Extensions { get; set; } = new Dictionary(); + public Dictionary? Extensions { get; set; } /// /// Parameter-less constructor diff --git a/src/Microsoft.OpenApi/Models/OpenApiComponents.cs b/src/Microsoft.OpenApi/Models/OpenApiComponents.cs index c3b762088..fb0129bec 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiComponents.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiComponents.cs @@ -19,60 +19,57 @@ public class OpenApiComponents : IOpenApiSerializable, IOpenApiExtensible /// /// An object to hold reusable Objects. /// - public IDictionary? Schemas { get; set; } = new Dictionary(); + public Dictionary? Schemas { get; set; } /// /// An object to hold reusable Objects. /// - public IDictionary? Responses { get; set; } = new Dictionary(); + public Dictionary? Responses { get; set; } /// /// An object to hold reusable Objects. /// - public IDictionary? Parameters { get; set; } = - new Dictionary(); + public Dictionary? Parameters { get; set; } /// /// An object to hold reusable Objects. /// - public IDictionary? Examples { get; set; } = new Dictionary(); + public Dictionary? Examples { get; set; } /// /// An object to hold reusable Objects. /// - public IDictionary? RequestBodies { get; set; } = - new Dictionary(); + public Dictionary? RequestBodies { get; set; } /// /// An object to hold reusable Objects. /// - public IDictionary? Headers { get; set; } = new Dictionary(); + public Dictionary? Headers { get; set; } /// /// An object to hold reusable Objects. /// - public IDictionary? SecuritySchemes { get; set; } = - new Dictionary(); + public Dictionary? SecuritySchemes { get; set; } /// /// An object to hold reusable Objects. /// - public IDictionary? Links { get; set; } = new Dictionary(); + public Dictionary? Links { get; set; } /// /// An object to hold reusable Objects. /// - public IDictionary? Callbacks { get; set; } = new Dictionary(); + public Dictionary? Callbacks { get; set; } /// /// An object to hold reusable Object. /// - public IDictionary? PathItems { get; set; } = new Dictionary(); + public Dictionary? PathItems { get; set; } /// /// This object MAY be extended with Specification Extensions. /// - public IDictionary? Extensions { get; set; } = new Dictionary(); + public Dictionary? Extensions { get; set; } /// /// Parameter-less constructor @@ -318,7 +315,7 @@ private void RenderComponents(IOpenApiWriter writer, Action /// This object MAY be extended with Specification Extensions. /// - public IDictionary? Extensions { get; set; } = new Dictionary(); + public Dictionary? Extensions { get; set; } /// /// Parameter-less constructor diff --git a/src/Microsoft.OpenApi/Models/OpenApiDiscriminator.cs b/src/Microsoft.OpenApi/Models/OpenApiDiscriminator.cs index 32a828c5b..8ad465241 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiDiscriminator.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiDiscriminator.cs @@ -21,12 +21,12 @@ public class OpenApiDiscriminator : IOpenApiSerializable, IOpenApiExtensible /// /// An object to hold mappings between payload values and schema names or references. /// - public IDictionary? Mapping { get; set; } = new Dictionary(); + public Dictionary? Mapping { get; set; } /// /// This object MAY be extended with Specification Extensions. /// - public IDictionary? Extensions { get; set; } = new Dictionary(); + public Dictionary? Extensions { get; set; } /// /// Parameter-less constructor diff --git a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs index e5f82e9cb..443123f9a 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs @@ -49,7 +49,7 @@ public void RegisterComponents() /// /// An array of Server Objects, which provide connectivity information to a target server. /// - public IList? Servers { get; set; } = new List(); + public List? Servers { get; set; } = []; /// /// REQUIRED. The available paths and operations for the API. @@ -61,7 +61,7 @@ public void RegisterComponents() /// A map of requests initiated other than by an API call, for example by an out of band registration. /// The key name is a unique string to refer to each webhook, while the (optionally referenced) Path Item Object describes a request that may be initiated by the API provider and the expected responses /// - public IDictionary? Webhooks { get; set; } = new Dictionary(); + public Dictionary? Webhooks { get; set; } /// /// An element to hold various schemas for the specification. @@ -71,14 +71,13 @@ public void RegisterComponents() /// /// A declaration of which security mechanisms can be used across the API. /// - public IList? Security { get; set; } = - new List(); + public List? Security { get; set; } private HashSet? _tags; /// /// A list of tags used by the specification with additional metadata. /// - public ISet? Tags + public HashSet? Tags { get { @@ -104,10 +103,10 @@ public ISet? Tags /// /// This object MAY be extended with Specification Extensions. /// - public IDictionary? Extensions { get; set; } = new Dictionary(); + public Dictionary? Extensions { get; set; } /// - public IDictionary? Metadata { get; set; } + public Dictionary? Metadata { get; set; } /// /// Implements IBaseDocument @@ -133,11 +132,11 @@ public OpenApiDocument(OpenApiDocument? document) Workspace = document?.Workspace != null ? new(document.Workspace) : null; Info = document?.Info != null ? new(document.Info) : new OpenApiInfo(); JsonSchemaDialect = document?.JsonSchemaDialect ?? JsonSchemaDialect; - Servers = document?.Servers != null ? new List(document.Servers) : null; - Paths = document?.Paths != null ? new(document.Paths) : new OpenApiPaths(); + Servers = document?.Servers != null ? [.. document.Servers] : null; + Paths = document?.Paths != null ? new(document.Paths) : []; Webhooks = document?.Webhooks != null ? new Dictionary(document.Webhooks) : null; Components = document?.Components != null ? new(document?.Components) : null; - Security = document?.Security != null ? new List(document.Security) : null; + Security = document?.Security != null ? [.. document.Security] : null; Tags = document?.Tags != null ? new HashSet(document.Tags, OpenApiTagComparer.Instance) : null; ExternalDocs = document?.ExternalDocs != null ? new(document.ExternalDocs) : null; Extensions = document?.Extensions != null ? new Dictionary(document.Extensions) : null; @@ -415,10 +414,10 @@ public void SerializeAsV2(IOpenApiWriter writer) private static string? ParseServerUrl(OpenApiServer server) { - return server.ReplaceServerUrlVariables(new Dictionary(0)); + return server.ReplaceServerUrlVariables([]); } - private static void WriteHostInfoV2(IOpenApiWriter writer, IList? servers) + private static void WriteHostInfoV2(IOpenApiWriter writer, List? servers) { if (servers == null || !servers.Any()) { @@ -652,43 +651,43 @@ public bool AddComponent(string id, T componentToRegister) switch (componentToRegister) { case IOpenApiSchema openApiSchema: - Components.Schemas ??= new Dictionary(); + Components.Schemas ??= []; Components.Schemas.Add(id, openApiSchema); break; case IOpenApiParameter openApiParameter: - Components.Parameters ??= new Dictionary(); + Components.Parameters ??= []; Components.Parameters.Add(id, openApiParameter); break; case IOpenApiResponse openApiResponse: - Components.Responses ??= new Dictionary(); + Components.Responses ??= []; Components.Responses.Add(id, openApiResponse); break; case IOpenApiRequestBody openApiRequestBody: - Components.RequestBodies ??= new Dictionary(); + Components.RequestBodies ??= []; Components.RequestBodies.Add(id, openApiRequestBody); break; case IOpenApiLink openApiLink: - Components.Links ??= new Dictionary(); + Components.Links ??= []; Components.Links.Add(id, openApiLink); break; case IOpenApiCallback openApiCallback: - Components.Callbacks ??= new Dictionary(); + Components.Callbacks ??= []; Components.Callbacks.Add(id, openApiCallback); break; case IOpenApiPathItem openApiPathItem: - Components.PathItems ??= new Dictionary(); + Components.PathItems ??= []; Components.PathItems.Add(id, openApiPathItem); break; case IOpenApiExample openApiExample: - Components.Examples ??= new Dictionary(); + Components.Examples ??= []; Components.Examples.Add(id, openApiExample); break; case IOpenApiHeader openApiHeader: - Components.Headers ??= new Dictionary(); + Components.Headers ??= []; Components.Headers.Add(id, openApiHeader); break; case IOpenApiSecurityScheme openApiSecurityScheme: - Components.SecuritySchemes ??= new Dictionary(); + Components.SecuritySchemes ??= []; Components.SecuritySchemes.Add(id, openApiSecurityScheme); break; default: diff --git a/src/Microsoft.OpenApi/Models/OpenApiEncoding.cs b/src/Microsoft.OpenApi/Models/OpenApiEncoding.cs index 4eae8e6ce..cc9340317 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiEncoding.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiEncoding.cs @@ -25,7 +25,7 @@ public class OpenApiEncoding : IOpenApiSerializable, IOpenApiExtensible /// /// A map allowing additional information to be provided as headers. /// - public IDictionary? Headers { get; set; } = new Dictionary(); + public Dictionary? Headers { get; set; } /// /// Describes how a specific property value will be serialized depending on its type. @@ -52,7 +52,7 @@ public class OpenApiEncoding : IOpenApiSerializable, IOpenApiExtensible /// /// This object MAY be extended with Specification Extensions. /// - public IDictionary? Extensions { get; set; } = new Dictionary(); + public Dictionary? Extensions { get; set; } /// /// Parameter-less constructor diff --git a/src/Microsoft.OpenApi/Models/OpenApiExample.cs b/src/Microsoft.OpenApi/Models/OpenApiExample.cs index 1470ca51a..6ffb26f2e 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiExample.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiExample.cs @@ -13,7 +13,7 @@ namespace Microsoft.OpenApi.Models /// /// Example Object. /// - public class OpenApiExample : IOpenApiReferenceable, IOpenApiExtensible, IOpenApiExample + public class OpenApiExample : IOpenApiExtensible, IOpenApiExample { /// public string? Summary { get; set; } @@ -28,7 +28,7 @@ public class OpenApiExample : IOpenApiReferenceable, IOpenApiExtensible, IOpenAp public JsonNode? Value { get; set; } /// - public IDictionary? Extensions { get; set; } = new Dictionary(); + public Dictionary? Extensions { get; set; } /// /// Parameter-less constructor diff --git a/src/Microsoft.OpenApi/Models/OpenApiExtensibleDictionary.cs b/src/Microsoft.OpenApi/Models/OpenApiExtensibleDictionary.cs index e9b07bf58..7e4f9f686 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiExtensibleDictionary.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiExtensibleDictionary.cs @@ -28,7 +28,7 @@ protected OpenApiExtensibleDictionary():this([]) { } /// The dictionary of . protected OpenApiExtensibleDictionary( Dictionary dictionary, - IDictionary? extensions = null) : base(dictionary is null ? [] : dictionary) + Dictionary? extensions = null) : base(dictionary is null ? [] : dictionary) { Extensions = extensions != null ? new Dictionary(extensions) : []; } @@ -36,7 +36,7 @@ protected OpenApiExtensibleDictionary( /// /// This object MAY be extended with Specification Extensions. /// - public IDictionary? Extensions { get; set; } + public Dictionary? Extensions { get; set; } /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiExternalDocs.cs b/src/Microsoft.OpenApi/Models/OpenApiExternalDocs.cs index 2694aa26a..381ee53bb 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiExternalDocs.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiExternalDocs.cs @@ -26,7 +26,7 @@ public class OpenApiExternalDocs : IOpenApiSerializable, IOpenApiExtensible /// /// This object MAY be extended with Specification Extensions. /// - public IDictionary? Extensions { get; set; } = new Dictionary(); + public Dictionary? Extensions { get; set; } /// /// Parameter-less constructor diff --git a/src/Microsoft.OpenApi/Models/OpenApiHeader.cs b/src/Microsoft.OpenApi/Models/OpenApiHeader.cs index 82d17aece..62bb09b89 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiHeader.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiHeader.cs @@ -47,13 +47,13 @@ public class OpenApiHeader : IOpenApiHeader, IOpenApiExtensible public JsonNode? Example { get; set; } /// - public IDictionary? Examples { get; set; } = new Dictionary(); + public Dictionary? Examples { get; set; } /// - public IDictionary? Content { get; set; } = new Dictionary(); + public Dictionary? Content { get; set; } /// - public IDictionary? Extensions { get; set; } = new Dictionary(); + public Dictionary? Extensions { get; set; } /// /// Parameter-less constructor diff --git a/src/Microsoft.OpenApi/Models/OpenApiInfo.cs b/src/Microsoft.OpenApi/Models/OpenApiInfo.cs index 93e89438c..119ae7eb1 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiInfo.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiInfo.cs @@ -51,7 +51,7 @@ public class OpenApiInfo : IOpenApiSerializable, IOpenApiExtensible /// /// This object MAY be extended with Specification Extensions. /// - public IDictionary? Extensions { get; set; } = new Dictionary(); + public Dictionary? Extensions { get; set; } /// /// Parameter-less constructor diff --git a/src/Microsoft.OpenApi/Models/OpenApiLicense.cs b/src/Microsoft.OpenApi/Models/OpenApiLicense.cs index 8aea264e6..c3c36812c 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiLicense.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiLicense.cs @@ -31,7 +31,7 @@ public class OpenApiLicense : IOpenApiSerializable, IOpenApiExtensible /// /// This object MAY be extended with Specification Extensions. /// - public IDictionary? Extensions { get; set; } = new Dictionary(); + public Dictionary? Extensions { get; set; } /// /// Parameterless constructor diff --git a/src/Microsoft.OpenApi/Models/OpenApiLink.cs b/src/Microsoft.OpenApi/Models/OpenApiLink.cs index 412577580..ea9202186 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiLink.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiLink.cs @@ -12,7 +12,7 @@ namespace Microsoft.OpenApi.Models /// /// Link Object. /// - public class OpenApiLink : IOpenApiReferenceable, IOpenApiExtensible, IOpenApiLink + public class OpenApiLink : IOpenApiExtensible, IOpenApiLink { /// public string? OperationRef { get; set; } @@ -21,7 +21,7 @@ public class OpenApiLink : IOpenApiReferenceable, IOpenApiExtensible, IOpenApiLi public string? OperationId { get; set; } /// - public IDictionary? Parameters { get; set; } = new Dictionary(); + public Dictionary? Parameters { get; set; } /// public RuntimeExpressionAnyWrapper? RequestBody { get; set; } @@ -33,7 +33,7 @@ public class OpenApiLink : IOpenApiReferenceable, IOpenApiExtensible, IOpenApiLi public OpenApiServer? Server { get; set; } /// - public IDictionary? Extensions { get; set; } = new Dictionary(); + public Dictionary? Extensions { get; set; } /// /// Parameterless constructor diff --git a/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs b/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs index 4c08ccccb..a16f8d11f 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs @@ -32,7 +32,7 @@ public class OpenApiMediaType : IOpenApiSerializable, IOpenApiExtensible /// Examples of the media type. /// Each example object SHOULD match the media type and specified schema if present. /// - public IDictionary? Examples { get; set; } = new Dictionary(); + public Dictionary? Examples { get; set; } /// /// A map between a property name and its encoding information. @@ -40,12 +40,12 @@ public class OpenApiMediaType : IOpenApiSerializable, IOpenApiExtensible /// The encoding object SHALL only apply to requestBody objects /// when the media type is multipart or application/x-www-form-urlencoded. /// - public IDictionary? Encoding { get; set; } = new Dictionary(); + public Dictionary? Encoding { get; set; } /// /// Serialize to Open Api v3.0. /// - public IDictionary? Extensions { get; set; } = new Dictionary(); + public Dictionary? Extensions { get; set; } /// /// Parameterless constructor @@ -119,7 +119,7 @@ public void SerializeAsV2(IOpenApiWriter writer) // Media type does not exist in V2. } - private static void SerializeExamples(IOpenApiWriter writer, IDictionary examples) + private static void SerializeExamples(IOpenApiWriter writer, Dictionary examples) { /* Special case for writing out empty arrays as valid response examples * Check if there is any example with an empty array as its value and set the flag `hasEmptyArray` to true diff --git a/src/Microsoft.OpenApi/Models/OpenApiOAuthFlow.cs b/src/Microsoft.OpenApi/Models/OpenApiOAuthFlow.cs index d84417cef..05c8da5e1 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiOAuthFlow.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiOAuthFlow.cs @@ -33,12 +33,12 @@ public class OpenApiOAuthFlow : IOpenApiSerializable, IOpenApiExtensible /// /// REQUIRED. A map between the scope name and a short description for it. /// - public IDictionary? Scopes { get; set; } = new Dictionary(); + public Dictionary? Scopes { get; set; } /// /// Specification Extensions. /// - public IDictionary? Extensions { get; set; } = new Dictionary(); + public Dictionary? Extensions { get; set; } /// /// Parameterless constructor diff --git a/src/Microsoft.OpenApi/Models/OpenApiOAuthFlows.cs b/src/Microsoft.OpenApi/Models/OpenApiOAuthFlows.cs index 758e1e02d..b46b41da1 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiOAuthFlows.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiOAuthFlows.cs @@ -36,7 +36,7 @@ public class OpenApiOAuthFlows : IOpenApiSerializable, IOpenApiExtensible /// /// Specification Extensions. /// - public IDictionary? Extensions { get; set; } = new Dictionary(); + public Dictionary? Extensions { get; set; } /// /// Parameterless constructor diff --git a/src/Microsoft.OpenApi/Models/OpenApiOperation.cs b/src/Microsoft.OpenApi/Models/OpenApiOperation.cs index 23a98f3d2..592d9cb58 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiOperation.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiOperation.cs @@ -26,7 +26,7 @@ public class OpenApiOperation : IOpenApiSerializable, IOpenApiExtensible, IMetad /// A list of tags for API documentation control. /// Tags can be used for logical grouping of operations by resources or any other qualifier. /// - public ISet? Tags + public HashSet? Tags { get { @@ -73,7 +73,7 @@ public ISet? Tags /// The list MUST NOT include duplicated parameters. A unique parameter is defined by a combination of a name and location. /// The list can use the Reference Object to link to parameters that are defined at the OpenAPI Object's components/parameters. /// - public IList? Parameters { get; set; } = []; + public List? Parameters { get; set; } /// /// The request body applicable for this operation. @@ -96,7 +96,7 @@ public ISet? Tags /// The key value used to identify the callback object is an expression, evaluated at runtime, /// that identifies a URL to use for the callback operation. /// - public IDictionary? Callbacks { get; set; } = new Dictionary(); + public Dictionary? Callbacks { get; set; } /// /// Declares this operation to be deprecated. Consumers SHOULD refrain from usage of the declared operation. @@ -110,22 +110,22 @@ public ISet? Tags /// This definition overrides any declared top-level security. /// To remove a top-level security declaration, an empty array can be used. /// - public IList? Security { get; set; } = new List(); + public List? Security { get; set; } /// /// An alternative server array to service this operation. /// If an alternative server object is specified at the Path Item Object or Root level, /// it will be overridden by this value. /// - public IList? Servers { get; set; } = new List(); + public List? Servers { get; set; } /// /// This object MAY be extended with Specification Extensions. /// - public IDictionary? Extensions { get; set; } = new Dictionary(); + public Dictionary? Extensions { get; set; } /// - public IDictionary? Metadata { get; set; } + public Dictionary? Metadata { get; set; } /// /// Parameterless constructor @@ -138,18 +138,18 @@ public OpenApiOperation() { } public OpenApiOperation(OpenApiOperation operation) { Utils.CheckArgumentNull(operation); - Tags = operation.Tags != null ? new HashSet(operation.Tags) : null; + Tags = operation.Tags != null ? [.. operation.Tags] : null; Summary = operation.Summary ?? Summary; Description = operation.Description ?? Description; ExternalDocs = operation.ExternalDocs != null ? new(operation.ExternalDocs) : null; OperationId = operation.OperationId ?? OperationId; - Parameters = operation.Parameters != null ? new List(operation.Parameters) : null; + Parameters = operation.Parameters != null ? [.. operation.Parameters] : null; RequestBody = operation.RequestBody?.CreateShallowCopy(); Responses = operation.Responses != null ? new(operation.Responses) : null; Callbacks = operation.Callbacks != null ? new Dictionary(operation.Callbacks) : null; Deprecated = operation.Deprecated; - Security = operation.Security != null ? new List(operation.Security) : null; - Servers = operation.Servers != null ? new List(operation.Servers) : null; + Security = operation.Security != null ? [.. operation.Security] : null; + Servers = operation.Servers != null ? [.. operation.Servers] : null; Extensions = operation.Extensions != null ? new Dictionary(operation.Extensions) : null; Metadata = operation.Metadata != null ? new Dictionary(operation.Metadata) : null; } @@ -293,7 +293,7 @@ public void SerializeAsV2(IOpenApiWriter writer) { var produces = Responses .Where(static r => r.Value.Content != null) - .SelectMany(static r => r.Value.Content?.Keys ?? []) + .SelectMany(static r => r.Value.Content?.Keys ?? Enumerable.Empty()) .Where(static m => !string.IsNullOrEmpty(m)) .Distinct(StringComparer.OrdinalIgnoreCase) .ToArray(); diff --git a/src/Microsoft.OpenApi/Models/OpenApiParameter.cs b/src/Microsoft.OpenApi/Models/OpenApiParameter.cs index 652e65b3d..fd74c2b57 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiParameter.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiParameter.cs @@ -61,16 +61,16 @@ public bool Explode public IOpenApiSchema? Schema { get; set; } /// - public IDictionary? Examples { get; set; } = new Dictionary(); + public Dictionary? Examples { get; set; } /// public JsonNode? Example { get; set; } /// - public IDictionary? Content { get; set; } = new Dictionary(); + public Dictionary? Content { get; set; } /// - public IDictionary? Extensions { get; set; } = new Dictionary(); + public Dictionary? Extensions { get; set; } /// /// A parameterless constructor diff --git a/src/Microsoft.OpenApi/Models/OpenApiPathItem.cs b/src/Microsoft.OpenApi/Models/OpenApiPathItem.cs index 6e89d9684..a001b922c 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiPathItem.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiPathItem.cs @@ -14,7 +14,7 @@ namespace Microsoft.OpenApi.Models /// /// Path Item Object: to describe the operations available on a single path. /// - public class OpenApiPathItem : IOpenApiExtensible, IOpenApiReferenceable, IOpenApiPathItem + public class OpenApiPathItem : IOpenApiExtensible, IOpenApiPathItem { /// public string? Summary { get; set; } @@ -23,17 +23,16 @@ public class OpenApiPathItem : IOpenApiExtensible, IOpenApiReferenceable, IOpenA public string? Description { get; set; } /// - public IDictionary? Operations { get; set; } - = new Dictionary(); + public Dictionary? Operations { get; set; } /// - public IList? Servers { get; set; } = []; + public List? Servers { get; set; } /// - public IList? Parameters { get; set; } = []; + public List? Parameters { get; set; } /// - public IDictionary? Extensions { get; set; } = new Dictionary(); + public Dictionary? Extensions { get; set; } /// /// Add one operation into this path item. @@ -42,10 +41,8 @@ public class OpenApiPathItem : IOpenApiExtensible, IOpenApiReferenceable, IOpenA /// The operation item. public void AddOperation(HttpMethod operationType, OpenApiOperation operation) { - if (Operations is not null) - { - Operations[operationType] = operation; - } + Operations ??= []; + Operations[operationType] = operation; } /// @@ -62,8 +59,8 @@ internal OpenApiPathItem(IOpenApiPathItem pathItem) Summary = pathItem.Summary ?? Summary; Description = pathItem.Description ?? Description; Operations = pathItem.Operations != null ? new Dictionary(pathItem.Operations) : null; - Servers = pathItem.Servers != null ? new List(pathItem.Servers) : null; - Parameters = pathItem.Parameters != null ? new List(pathItem.Parameters) : null; + Servers = pathItem.Servers != null ? [.. pathItem.Servers] : null; + Parameters = pathItem.Parameters != null ? [.. pathItem.Parameters] : null; Extensions = pathItem.Extensions != null ? new Dictionary(pathItem.Extensions) : null; } diff --git a/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs b/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs index 70d1a1309..302cfc5ae 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs @@ -16,7 +16,7 @@ namespace Microsoft.OpenApi.Models /// /// Request Body Object /// - public class OpenApiRequestBody : IOpenApiReferenceable, IOpenApiExtensible, IOpenApiRequestBody + public class OpenApiRequestBody : IOpenApiExtensible, IOpenApiRequestBody { /// public string? Description { get; set; } @@ -25,10 +25,10 @@ public class OpenApiRequestBody : IOpenApiReferenceable, IOpenApiExtensible, IOp public bool Required { get; set; } /// - public IDictionary? Content { get; set; } = new Dictionary(); + public Dictionary? Content { get; set; } /// - public IDictionary? Extensions { get; set; } = new Dictionary(); + public Dictionary? Extensions { get; set; } /// /// Parameter-less constructor diff --git a/src/Microsoft.OpenApi/Models/OpenApiResponse.cs b/src/Microsoft.OpenApi/Models/OpenApiResponse.cs index 9c8459e2b..13ab81152 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiResponse.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiResponse.cs @@ -13,22 +13,22 @@ namespace Microsoft.OpenApi.Models /// /// Response object. /// - public class OpenApiResponse : IOpenApiReferenceable, IOpenApiExtensible, IOpenApiResponse + public class OpenApiResponse : IOpenApiExtensible, IOpenApiResponse { /// public string? Description { get; set; } /// - public IDictionary? Headers { get; set; } = new Dictionary(); + public Dictionary? Headers { get; set; } /// - public IDictionary? Content { get; set; } = new Dictionary(); + public Dictionary? Content { get; set; } /// - public IDictionary? Links { get; set; } = new Dictionary(); + public Dictionary? Links { get; set; } /// - public IDictionary? Extensions { get; set; } = new Dictionary(); + public Dictionary? Extensions { get; set; } /// /// Parameterless constructor @@ -136,7 +136,7 @@ public void SerializeAsV2(IOpenApiWriter writer) foreach (var example in Content .Select(static x => x.Value.Examples) - .OfType>() + .OfType>() .SelectMany(static x => x)) { writer.WritePropertyName(example.Key); diff --git a/src/Microsoft.OpenApi/Models/OpenApiSchema.cs b/src/Microsoft.OpenApi/Models/OpenApiSchema.cs index 8c1f5d596..28c3e30c9 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiSchema.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiSchema.cs @@ -33,7 +33,7 @@ public class OpenApiSchema : IOpenApiExtensible, IOpenApiSchema public string? Comment { get; set; } /// - public IDictionary? Vocabulary { get; set; } + public Dictionary? Vocabulary { get; set; } /// public string? DynamicRef { get; set; } @@ -42,7 +42,7 @@ public class OpenApiSchema : IOpenApiExtensible, IOpenApiSchema public string? DynamicAnchor { get; set; } /// - public IDictionary? Definitions { get; set; } + public Dictionary? Definitions { get; set; } private string? _exclusiveMaximum; /// @@ -173,19 +173,19 @@ public string? Minimum public bool WriteOnly { get; set; } /// - public IList? AllOf { get; set; } = []; + public List? AllOf { get; set; } /// - public IList? OneOf { get; set; } = []; + public List? OneOf { get; set; } /// - public IList? AnyOf { get; set; } = []; + public List? AnyOf { get; set; } /// public IOpenApiSchema? Not { get; set; } /// - public ISet? Required { get; set; } = new HashSet(); + public HashSet? Required { get; set; } /// public IOpenApiSchema? Items { get; set; } @@ -200,10 +200,10 @@ public string? Minimum public bool? UniqueItems { get; set; } /// - public IDictionary? Properties { get; set; } = new Dictionary(StringComparer.Ordinal); + public Dictionary? Properties { get; set; } /// - public IDictionary? PatternProperties { get; set; } = new Dictionary(StringComparer.Ordinal); + public Dictionary? PatternProperties { get; set; } /// public int? MaxProperties { get; set; } @@ -224,13 +224,13 @@ public string? Minimum public JsonNode? Example { get; set; } /// - public IList? Examples { get; set; } + public List? Examples { get; set; } /// - public IList? Enum { get; set; } = new List(); + public List? Enum { get; set; } /// - public bool UnevaluatedProperties { get; set;} + public bool UnevaluatedProperties { get; set; } /// public OpenApiExternalDocs? ExternalDocs { get; set; } @@ -242,16 +242,16 @@ public string? Minimum public OpenApiXml? Xml { get; set; } /// - public IDictionary? Extensions { get; set; } = new Dictionary(); + public Dictionary? Extensions { get; set; } /// - public IDictionary? UnrecognizedKeywords { get; set; } = new Dictionary(); + public Dictionary? UnrecognizedKeywords { get; set; } /// - public IDictionary? Annotations { get; set; } + public Dictionary? Annotations { get; set; } /// - public IDictionary>? DependentRequired { get; set; } = new Dictionary>(); + public Dictionary>? DependentRequired { get; set; } /// /// Parameterless constructor @@ -294,11 +294,11 @@ internal OpenApiSchema(IOpenApiSchema schema) Default = schema.Default != null ? JsonNodeCloneHelper.Clone(schema.Default) : null; ReadOnly = schema.ReadOnly; WriteOnly = schema.WriteOnly; - AllOf = schema.AllOf != null ? new List(schema.AllOf) : null; - OneOf = schema.OneOf != null ? new List(schema.OneOf) : null; - AnyOf = schema.AnyOf != null ? new List(schema.AnyOf) : null; + AllOf = schema.AllOf != null ? [.. schema.AllOf] : null; + OneOf = schema.OneOf != null ? [.. schema.OneOf] : null; + AnyOf = schema.AnyOf != null ? [.. schema.AnyOf] : null; Not = schema.Not?.CreateShallowCopy(); - Required = schema.Required != null ? new HashSet(schema.Required) : null; + Required = schema.Required != null ? [.. schema.Required] : null; Items = schema.Items?.CreateShallowCopy(); MaxItems = schema.MaxItems ?? MaxItems; MinItems = schema.MinItems ?? MinItems; @@ -309,17 +309,17 @@ internal OpenApiSchema(IOpenApiSchema schema) MinProperties = schema.MinProperties ?? MinProperties; AdditionalPropertiesAllowed = schema.AdditionalPropertiesAllowed; AdditionalProperties = schema.AdditionalProperties?.CreateShallowCopy(); - Discriminator = schema.Discriminator != null ? new(schema.Discriminator) : null; + Discriminator = schema.Discriminator != null ? new(schema.Discriminator) : null; Example = schema.Example != null ? JsonNodeCloneHelper.Clone(schema.Example) : null; - Examples = schema.Examples != null ? new List(schema.Examples) : null; - Enum = schema.Enum != null ? new List(schema.Enum) : null; + Examples = schema.Examples != null ? [.. schema.Examples] : null; + Enum = schema.Enum != null ? [.. schema.Enum] : null; ExternalDocs = schema.ExternalDocs != null ? new(schema.ExternalDocs) : null; Deprecated = schema.Deprecated; Xml = schema.Xml != null ? new(schema.Xml) : null; Extensions = schema.Extensions != null ? new Dictionary(schema.Extensions) : null; Annotations = schema.Annotations != null ? new Dictionary(schema.Annotations) : null; UnrecognizedKeywords = schema.UnrecognizedKeywords != null ? new Dictionary(schema.UnrecognizedKeywords) : null; - DependentRequired = schema.DependentRequired != null ? new Dictionary>(schema.DependentRequired) : null; + DependentRequired = schema.DependentRequired != null ? new Dictionary>(schema.DependentRequired) : null; } /// @@ -426,7 +426,7 @@ private void SerializeInternal(IOpenApiWriter writer, OpenApiSpecVersion version writer.WriteProperty(OpenApiConstants.MinProperties, MinProperties); // required - writer.WriteOptionalCollection(OpenApiConstants.Required, Required, (w, s) => + writer.WriteOptionalCollection(OpenApiConstants.Required, Required, (w, s) => { if (!string.IsNullOrEmpty(s) && s is not null) { @@ -507,7 +507,7 @@ private void SerializeInternal(IOpenApiWriter writer, OpenApiSpecVersion version // Unrecognized keywords if (UnrecognizedKeywords is not null && UnrecognizedKeywords.Any()) { - writer.WriteOptionalMap(OpenApiConstants.UnrecognizedKeywords, UnrecognizedKeywords, (w,s) => w.WriteAny(s)); + writer.WriteOptionalMap(OpenApiConstants.UnrecognizedKeywords, UnrecognizedKeywords, (w, s) => w.WriteAny(s)); } writer.WriteEndObject(); @@ -612,7 +612,7 @@ private void WriteFormatProperty(IOpenApiWriter writer) /// The property name that will be serialized. private void SerializeAsV2( IOpenApiWriter writer, - ISet? parentRequiredProperties, + HashSet? parentRequiredProperties, string? propertyName) { parentRequiredProperties ??= new HashSet(); @@ -670,7 +670,7 @@ private void SerializeAsV2( writer.WriteProperty(OpenApiConstants.MinProperties, MinProperties); // required - writer.WriteOptionalCollection(OpenApiConstants.Required, Required, (w, s) => + writer.WriteOptionalCollection(OpenApiConstants.Required, Required, (w, s) => { if (!string.IsNullOrEmpty(s) && s is not null) { @@ -754,7 +754,7 @@ private void SerializeTypeProperty(JsonSchemaType? type, IOpenApiWriter writer, // check whether nullable is true for upcasting purposes var isNullable = (Type.HasValue && Type.Value.HasFlag(JsonSchemaType.Null)) || Extensions is not null && - Extensions.TryGetValue(OpenApiConstants.NullableExtension, out var nullExtRawValue) && + Extensions.TryGetValue(OpenApiConstants.NullableExtension, out var nullExtRawValue) && nullExtRawValue is OpenApiAny { Node: JsonNode jsonNode } && jsonNode.GetValueKind() is JsonValueKind.True; if (type is null) @@ -766,7 +766,7 @@ Extensions is not null && } else if (!HasMultipleTypes(type.Value)) { - + switch (version) { case OpenApiSpecVersion.OpenApi3_1 when isNullable: @@ -799,13 +799,13 @@ where type.Value.HasFlag(flag) select flag).ToList(); writer.WriteOptionalCollection(OpenApiConstants.Type, list, (w, s) => { - foreach(var item in s.ToIdentifiers()) + foreach (var item in s.ToIdentifiers()) { w.WriteValue(item); } }); } - } + } } private static bool IsPowerOfTwo(int x) @@ -829,7 +829,7 @@ where temporaryType.HasFlag(flag) select flag.ToFirstIdentifier()).ToList(); if (list.Count > 1) { - writer.WriteOptionalCollection(OpenApiConstants.Type, list, (w, s) => + writer.WriteOptionalCollection(OpenApiConstants.Type, list, (w, s) => { if (!string.IsNullOrEmpty(s) && s is not null) { @@ -849,7 +849,7 @@ where temporaryType.HasFlag(flag) private static readonly Array jsonSchemaTypeValues = System.Enum.GetValues(typeof(JsonSchemaType)); #endif - private void DowncastTypeArrayToV2OrV3(JsonSchemaType schemaType, IOpenApiWriter writer, OpenApiSpecVersion version) + private static void DowncastTypeArrayToV2OrV3(JsonSchemaType schemaType, IOpenApiWriter writer, OpenApiSpecVersion version) { /* If the array has one non-null value, emit Type as string * If the array has one null value, emit x-nullable as true diff --git a/src/Microsoft.OpenApi/Models/OpenApiSecurityRequirement.cs b/src/Microsoft.OpenApi/Models/OpenApiSecurityRequirement.cs index 7b2e70d3c..f9d40682b 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiSecurityRequirement.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiSecurityRequirement.cs @@ -19,7 +19,7 @@ namespace Microsoft.OpenApi.Models /// then the value is a list of scope names required for the execution. /// For other security scheme types, the array MUST be empty. /// - public class OpenApiSecurityRequirement : Dictionary>, + public class OpenApiSecurityRequirement : Dictionary>, IOpenApiSerializable { /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs b/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs index 7d254a3d2..992fe7986 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs @@ -13,7 +13,7 @@ namespace Microsoft.OpenApi.Models /// /// Security Scheme Object. /// - public class OpenApiSecurityScheme : IOpenApiExtensible, IOpenApiReferenceable, IOpenApiSecurityScheme + public class OpenApiSecurityScheme : IOpenApiExtensible, IOpenApiSecurityScheme { /// public SecuritySchemeType? Type { get; set; } @@ -40,7 +40,7 @@ public class OpenApiSecurityScheme : IOpenApiExtensible, IOpenApiReferenceable, public Uri? OpenIdConnectUrl { get; set; } /// - public IDictionary? Extensions { get; set; } = new Dictionary(); + public Dictionary? Extensions { get; set; } /// /// Parameterless constructor diff --git a/src/Microsoft.OpenApi/Models/OpenApiServer.cs b/src/Microsoft.OpenApi/Models/OpenApiServer.cs index a15c6068e..9c5b3cfca 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiServer.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiServer.cs @@ -28,13 +28,12 @@ public class OpenApiServer : IOpenApiSerializable, IOpenApiExtensible /// /// A map between a variable name and its value. The value is used for substitution in the server's URL template. /// - public IDictionary? Variables { get; set; } = - new Dictionary(); + public Dictionary? Variables { get; set; } /// /// This object MAY be extended with Specification Extensions. /// - public IDictionary? Extensions { get; set; } = new Dictionary(); + public Dictionary? Extensions { get; set; } /// /// Parameterless constructor diff --git a/src/Microsoft.OpenApi/Models/OpenApiServerVariable.cs b/src/Microsoft.OpenApi/Models/OpenApiServerVariable.cs index 9c46f20a8..793c94d6c 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiServerVariable.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiServerVariable.cs @@ -34,7 +34,7 @@ public class OpenApiServerVariable : IOpenApiSerializable, IOpenApiExtensible /// /// This object MAY be extended with Specification Extensions. /// - public IDictionary? Extensions { get; set; } = new Dictionary(); + public Dictionary? Extensions { get; set; } /// /// Parameterless constructor diff --git a/src/Microsoft.OpenApi/Models/OpenApiTag.cs b/src/Microsoft.OpenApi/Models/OpenApiTag.cs index 48ac2960c..253fab1de 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiTag.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiTag.cs @@ -12,7 +12,7 @@ namespace Microsoft.OpenApi.Models /// /// Tag Object. /// - public class OpenApiTag : IOpenApiExtensible, IOpenApiReferenceable, IOpenApiTag, IOpenApiDescribedElement + public class OpenApiTag : IOpenApiExtensible, IOpenApiTag, IOpenApiDescribedElement { /// public string? Name { get; set; } @@ -24,7 +24,7 @@ public class OpenApiTag : IOpenApiExtensible, IOpenApiReferenceable, IOpenApiTag public OpenApiExternalDocs? ExternalDocs { get; set; } /// - public IDictionary? Extensions { get; set; } = new Dictionary(); + public Dictionary? Extensions { get; set; } /// /// Parameterless constructor diff --git a/src/Microsoft.OpenApi/Models/OpenApiXml.cs b/src/Microsoft.OpenApi/Models/OpenApiXml.cs index c0503e14d..ae8a94a46 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiXml.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiXml.cs @@ -43,7 +43,7 @@ public class OpenApiXml : IOpenApiSerializable, IOpenApiExtensible /// /// Specification Extensions. /// - public IDictionary? Extensions { get; set; } = new Dictionary(); + public Dictionary? Extensions { get; set; } /// /// Parameterless constructor diff --git a/src/Microsoft.OpenApi/Models/References/OpenApiCallbackReference.cs b/src/Microsoft.OpenApi/Models/References/OpenApiCallbackReference.cs index d1a06da15..1211561e4 100644 --- a/src/Microsoft.OpenApi/Models/References/OpenApiCallbackReference.cs +++ b/src/Microsoft.OpenApi/Models/References/OpenApiCallbackReference.cs @@ -41,7 +41,7 @@ private OpenApiCallbackReference(OpenApiCallbackReference callback):base(callbac public Dictionary? PathItems { get => Target?.PathItems; } /// - public IDictionary? Extensions { get => Target?.Extensions; } + public Dictionary? Extensions { get => Target?.Extensions; } /// public override IOpenApiCallback CopyReferenceAsTargetElementWithOverrides(IOpenApiCallback source) diff --git a/src/Microsoft.OpenApi/Models/References/OpenApiExampleReference.cs b/src/Microsoft.OpenApi/Models/References/OpenApiExampleReference.cs index b1c1ae8ae..59cb7319e 100644 --- a/src/Microsoft.OpenApi/Models/References/OpenApiExampleReference.cs +++ b/src/Microsoft.OpenApi/Models/References/OpenApiExampleReference.cs @@ -51,7 +51,7 @@ public string? Summary } /// - public IDictionary? Extensions { get => Target?.Extensions; } + public Dictionary? Extensions { get => Target?.Extensions; } /// public string? ExternalValue { get => Target?.ExternalValue; } diff --git a/src/Microsoft.OpenApi/Models/References/OpenApiHeaderReference.cs b/src/Microsoft.OpenApi/Models/References/OpenApiHeaderReference.cs index cd843de57..fa8fe15eb 100644 --- a/src/Microsoft.OpenApi/Models/References/OpenApiHeaderReference.cs +++ b/src/Microsoft.OpenApi/Models/References/OpenApiHeaderReference.cs @@ -68,13 +68,13 @@ public string? Description public JsonNode? Example { get => Target?.Example; } /// - public IDictionary? Examples { get => Target?.Examples; } + public Dictionary? Examples { get => Target?.Examples; } /// - public IDictionary? Content { get => Target?.Content; } + public Dictionary? Content { get => Target?.Content; } /// - public IDictionary? Extensions { get => Target?.Extensions; } + public Dictionary? Extensions { get => Target?.Extensions; } /// public override IOpenApiHeader CopyReferenceAsTargetElementWithOverrides(IOpenApiHeader source) diff --git a/src/Microsoft.OpenApi/Models/References/OpenApiLinkReference.cs b/src/Microsoft.OpenApi/Models/References/OpenApiLinkReference.cs index 8c23cdf35..71f52ecd9 100644 --- a/src/Microsoft.OpenApi/Models/References/OpenApiLinkReference.cs +++ b/src/Microsoft.OpenApi/Models/References/OpenApiLinkReference.cs @@ -52,13 +52,13 @@ public string? Description public OpenApiServer? Server { get => Target?.Server; } /// - public IDictionary? Parameters { get => Target?.Parameters; } + public Dictionary? Parameters { get => Target?.Parameters; } /// public RuntimeExpressionAnyWrapper? RequestBody { get => Target?.RequestBody; } /// - public IDictionary? Extensions { get => Target?.Extensions; } + public Dictionary? Extensions { get => Target?.Extensions; } /// public override void SerializeAsV2(IOpenApiWriter writer) diff --git a/src/Microsoft.OpenApi/Models/References/OpenApiParameterReference.cs b/src/Microsoft.OpenApi/Models/References/OpenApiParameterReference.cs index 40ecb69eb..ae9322e41 100644 --- a/src/Microsoft.OpenApi/Models/References/OpenApiParameterReference.cs +++ b/src/Microsoft.OpenApi/Models/References/OpenApiParameterReference.cs @@ -61,7 +61,7 @@ public string? Description public IOpenApiSchema? Schema { get => Target?.Schema; } /// - public IDictionary? Examples { get => Target?.Examples; } + public Dictionary? Examples { get => Target?.Examples; } /// public JsonNode? Example { get => Target?.Example; } @@ -76,10 +76,10 @@ public string? Description public bool Explode { get => Target?.Explode ?? default; } /// - public IDictionary? Content { get => Target?.Content; } + public Dictionary? Content { get => Target?.Content; } /// - public IDictionary? Extensions { get => Target?.Extensions; } + public Dictionary? Extensions { get => Target?.Extensions; } /// public override IOpenApiParameter CopyReferenceAsTargetElementWithOverrides(IOpenApiParameter source) diff --git a/src/Microsoft.OpenApi/Models/References/OpenApiPathItemReference.cs b/src/Microsoft.OpenApi/Models/References/OpenApiPathItemReference.cs index bfd9f8ceb..a6ae2d405 100644 --- a/src/Microsoft.OpenApi/Models/References/OpenApiPathItemReference.cs +++ b/src/Microsoft.OpenApi/Models/References/OpenApiPathItemReference.cs @@ -53,16 +53,16 @@ public string? Description } /// - public IDictionary? Operations { get => Target?.Operations; } + public Dictionary? Operations { get => Target?.Operations; } /// - public IList? Servers { get => Target?.Servers; } + public List? Servers { get => Target?.Servers; } /// - public IList? Parameters { get => Target?.Parameters; } + public List? Parameters { get => Target?.Parameters; } /// - public IDictionary? Extensions { get => Target?.Extensions; } + public Dictionary? Extensions { get => Target?.Extensions; } /// public override IOpenApiPathItem CopyReferenceAsTargetElementWithOverrides(IOpenApiPathItem source) diff --git a/src/Microsoft.OpenApi/Models/References/OpenApiRequestBodyReference.cs b/src/Microsoft.OpenApi/Models/References/OpenApiRequestBodyReference.cs index 8beb3e604..f6bee476b 100644 --- a/src/Microsoft.OpenApi/Models/References/OpenApiRequestBodyReference.cs +++ b/src/Microsoft.OpenApi/Models/References/OpenApiRequestBodyReference.cs @@ -45,13 +45,13 @@ public string? Description } /// - public IDictionary? Content { get => Target?.Content; } + public Dictionary? Content { get => Target?.Content; } /// public bool Required { get => Target?.Required ?? false; } /// - public IDictionary? Extensions { get => Target?.Extensions; } + public Dictionary? Extensions { get => Target?.Extensions; } /// public override IOpenApiRequestBody CopyReferenceAsTargetElementWithOverrides(IOpenApiRequestBody source) diff --git a/src/Microsoft.OpenApi/Models/References/OpenApiResponseReference.cs b/src/Microsoft.OpenApi/Models/References/OpenApiResponseReference.cs index cc78f6080..648b9c4c6 100644 --- a/src/Microsoft.OpenApi/Models/References/OpenApiResponseReference.cs +++ b/src/Microsoft.OpenApi/Models/References/OpenApiResponseReference.cs @@ -43,16 +43,16 @@ public string? Description } /// - public IDictionary? Content { get => Target?.Content; } + public Dictionary? Content { get => Target?.Content; } /// - public IDictionary? Headers { get => Target?.Headers; } + public Dictionary? Headers { get => Target?.Headers; } /// - public IDictionary? Links { get => Target?.Links; } + public Dictionary? Links { get => Target?.Links; } /// - public IDictionary? Extensions { get => Target?.Extensions; } + public Dictionary? Extensions { get => Target?.Extensions; } /// public override IOpenApiResponse CopyReferenceAsTargetElementWithOverrides(IOpenApiResponse source) diff --git a/src/Microsoft.OpenApi/Models/References/OpenApiSchemaReference.cs b/src/Microsoft.OpenApi/Models/References/OpenApiSchemaReference.cs index fb817f56b..7dd3ea3e5 100644 --- a/src/Microsoft.OpenApi/Models/References/OpenApiSchemaReference.cs +++ b/src/Microsoft.OpenApi/Models/References/OpenApiSchemaReference.cs @@ -52,13 +52,13 @@ public string? Description /// public string? Comment { get => Target?.Comment; } /// - public IDictionary? Vocabulary { get => Target?.Vocabulary; } + public Dictionary? Vocabulary { get => Target?.Vocabulary; } /// public string? DynamicRef { get => Target?.DynamicRef; } /// public string? DynamicAnchor { get => Target?.DynamicAnchor; } /// - public IDictionary? Definitions { get => Target?.Definitions; } + public Dictionary? Definitions { get => Target?.Definitions; } /// public string? ExclusiveMaximum { get => Target?.ExclusiveMaximum; } /// @@ -88,15 +88,15 @@ public string? Description /// public bool WriteOnly { get => Target?.WriteOnly ?? false; } /// - public IList? AllOf { get => Target?.AllOf; } + public List? AllOf { get => Target?.AllOf; } /// - public IList? OneOf { get => Target?.OneOf; } + public List? OneOf { get => Target?.OneOf; } /// - public IList? AnyOf { get => Target?.AnyOf; } + public List? AnyOf { get => Target?.AnyOf; } /// public IOpenApiSchema? Not { get => Target?.Not; } /// - public ISet? Required { get => Target?.Required; } + public HashSet? Required { get => Target?.Required; } /// public IOpenApiSchema? Items { get => Target?.Items; } /// @@ -106,9 +106,9 @@ public string? Description /// public bool? UniqueItems { get => Target?.UniqueItems; } /// - public IDictionary? Properties { get => Target?.Properties; } + public Dictionary? Properties { get => Target?.Properties; } /// - public IDictionary? PatternProperties { get => Target?.PatternProperties; } + public Dictionary? PatternProperties { get => Target?.PatternProperties; } /// public int? MaxProperties { get => Target?.MaxProperties; } /// @@ -122,9 +122,9 @@ public string? Description /// public JsonNode? Example { get => Target?.Example; } /// - public IList? Examples { get => Target?.Examples; } + public List? Examples { get => Target?.Examples; } /// - public IList? Enum { get => Target?.Enum; } + public List? Enum { get => Target?.Enum; } /// public bool UnevaluatedProperties { get => Target?.UnevaluatedProperties ?? false; } /// @@ -134,16 +134,16 @@ public string? Description /// public OpenApiXml? Xml { get => Target?.Xml; } /// - public IDictionary? Extensions { get => Target?.Extensions; } + public Dictionary? Extensions { get => Target?.Extensions; } /// - public IDictionary? UnrecognizedKeywords { get => Target?.UnrecognizedKeywords; } + public Dictionary? UnrecognizedKeywords { get => Target?.UnrecognizedKeywords; } /// - public IDictionary? Annotations { get => Target?.Annotations; } + public Dictionary? Annotations { get => Target?.Annotations; } /// - public IDictionary>? DependentRequired { get => Target?.DependentRequired; } + public Dictionary>? DependentRequired { get => Target?.DependentRequired; } /// public override void SerializeAsV31(IOpenApiWriter writer) diff --git a/src/Microsoft.OpenApi/Models/References/OpenApiSecuritySchemeReference.cs b/src/Microsoft.OpenApi/Models/References/OpenApiSecuritySchemeReference.cs index 44741467b..ff9c5b396 100644 --- a/src/Microsoft.OpenApi/Models/References/OpenApiSecuritySchemeReference.cs +++ b/src/Microsoft.OpenApi/Models/References/OpenApiSecuritySchemeReference.cs @@ -57,7 +57,7 @@ public string? Description public Uri? OpenIdConnectUrl { get => Target?.OpenIdConnectUrl; } /// - public IDictionary? Extensions { get => Target?.Extensions; } + public Dictionary? Extensions { get => Target?.Extensions; } /// public SecuritySchemeType? Type { get => Target?.Type; } diff --git a/src/Microsoft.OpenApi/Models/References/OpenApiTagReference.cs b/src/Microsoft.OpenApi/Models/References/OpenApiTagReference.cs index 59255a8b6..cd3af84ba 100644 --- a/src/Microsoft.OpenApi/Models/References/OpenApiTagReference.cs +++ b/src/Microsoft.OpenApi/Models/References/OpenApiTagReference.cs @@ -57,7 +57,7 @@ public string? Description public OpenApiExternalDocs? ExternalDocs { get => Target?.ExternalDocs; } /// - public IDictionary? Extensions { get => Target?.Extensions; } + public Dictionary? Extensions { get => Target?.Extensions; } /// public string? Name { get => Target?.Name; } diff --git a/src/Microsoft.OpenApi/Reader/OpenApiDiagnostic.cs b/src/Microsoft.OpenApi/Reader/OpenApiDiagnostic.cs index 247bb2ba8..be718c28d 100644 --- a/src/Microsoft.OpenApi/Reader/OpenApiDiagnostic.cs +++ b/src/Microsoft.OpenApi/Reader/OpenApiDiagnostic.cs @@ -15,12 +15,12 @@ public class OpenApiDiagnostic : IDiagnostic /// /// List of all errors. /// - public IList Errors { get; set; } = new List(); + public List Errors { get; set; } = []; /// /// List of all warnings /// - public IList Warnings { get; set; } = new List(); + public List Warnings { get; set; } = []; /// /// Open API specification version of the document parsed. diff --git a/src/Microsoft.OpenApi/Reader/ParseNodes/AnyListFieldMapParameter.cs b/src/Microsoft.OpenApi/Reader/ParseNodes/AnyListFieldMapParameter.cs index 873f0df15..a096b5a08 100644 --- a/src/Microsoft.OpenApi/Reader/ParseNodes/AnyListFieldMapParameter.cs +++ b/src/Microsoft.OpenApi/Reader/ParseNodes/AnyListFieldMapParameter.cs @@ -14,8 +14,8 @@ internal class AnyListFieldMapParameter /// Constructor /// public AnyListFieldMapParameter( - Func> propertyGetter, - Action> propertySetter, + Func> propertyGetter, + Action> propertySetter, Func? SchemaGetter = null) { this.PropertyGetter = propertyGetter; @@ -26,12 +26,12 @@ public AnyListFieldMapParameter( /// /// Function to retrieve the value of the property. /// - public Func> PropertyGetter { get; } + public Func> PropertyGetter { get; } /// /// Function to set the value of the property. /// - public Action> PropertySetter { get; } + public Action> PropertySetter { get; } /// /// Function to get the schema to apply to the property. diff --git a/src/Microsoft.OpenApi/Reader/ParseNodes/AnyMapFieldMapParameter.cs b/src/Microsoft.OpenApi/Reader/ParseNodes/AnyMapFieldMapParameter.cs index 6a16f4e46..883aa137b 100644 --- a/src/Microsoft.OpenApi/Reader/ParseNodes/AnyMapFieldMapParameter.cs +++ b/src/Microsoft.OpenApi/Reader/ParseNodes/AnyMapFieldMapParameter.cs @@ -15,7 +15,7 @@ internal class AnyMapFieldMapParameter /// Constructor /// public AnyMapFieldMapParameter( - Func?> propertyMapGetter, + Func?> propertyMapGetter, Func propertyGetter, Action propertySetter, Func schemaGetter) @@ -29,7 +29,7 @@ public AnyMapFieldMapParameter( /// /// Function to retrieve the property that is a map from string to an inner element containing IOpenApiAny. /// - public Func?> PropertyMapGetter { get; } + public Func?> PropertyMapGetter { get; } /// /// Function to retrieve the value of the property from an inner element. diff --git a/src/Microsoft.OpenApi/Reader/ParseNodes/MapNode.cs b/src/Microsoft.OpenApi/Reader/ParseNodes/MapNode.cs index 3d3ef71af..ae7adefa6 100644 --- a/src/Microsoft.OpenApi/Reader/ParseNodes/MapNode.cs +++ b/src/Microsoft.OpenApi/Reader/ParseNodes/MapNode.cs @@ -102,7 +102,7 @@ public override Dictionary CreateSimpleMap(Func map) return nodes.ToDictionary(k => k.key, v => v.value); } - public override Dictionary> CreateArrayMap(Func map, OpenApiDocument? openApiDocument) + public override Dictionary> CreateArrayMap(Func map, OpenApiDocument? openApiDocument) { var jsonMap = _node ?? throw new OpenApiReaderException($"Expected map while parsing {typeof(T).Name}", Context); @@ -116,7 +116,7 @@ public override Dictionary> CreateArrayMap(Func values = new HashSet(arrayNode.OfType().Select(item => map(new ValueNode(Context, item), openApiDocument))); + HashSet values = new HashSet(arrayNode.OfType().Select(item => map(new ValueNode(Context, item), openApiDocument))); return (key, values); diff --git a/src/Microsoft.OpenApi/Reader/ParseNodes/ParseNode.cs b/src/Microsoft.OpenApi/Reader/ParseNodes/ParseNode.cs index 699022193..6c62fa0b8 100644 --- a/src/Microsoft.OpenApi/Reader/ParseNodes/ParseNode.cs +++ b/src/Microsoft.OpenApi/Reader/ParseNodes/ParseNode.cs @@ -86,7 +86,7 @@ public virtual List CreateListOfAny() throw new OpenApiReaderException("Cannot create a list from this type of node.", Context); } - public virtual Dictionary> CreateArrayMap(Func map, OpenApiDocument? openApiDocument) + public virtual Dictionary> CreateArrayMap(Func map, OpenApiDocument? openApiDocument) { throw new OpenApiReaderException("Cannot create array map from this type of node.", Context); } diff --git a/src/Microsoft.OpenApi/Reader/ParseNodes/PropertyNode.cs b/src/Microsoft.OpenApi/Reader/ParseNodes/PropertyNode.cs index 9517e5363..4a3fd0336 100644 --- a/src/Microsoft.OpenApi/Reader/ParseNodes/PropertyNode.cs +++ b/src/Microsoft.OpenApi/Reader/ParseNodes/PropertyNode.cs @@ -25,8 +25,8 @@ public PropertyNode(ParsingContext context, string name, JsonNode node) : base( public void ParseField( T parentInstance, - IDictionary> fixedFields, - IDictionary, Action> patternFields, + Dictionary> fixedFields, + Dictionary, Action> patternFields, OpenApiDocument hostDocument) { if (fixedFields.TryGetValue(Name, out var fixedFieldMap)) diff --git a/src/Microsoft.OpenApi/Reader/V2/OpenApiDocumentDeserializer.cs b/src/Microsoft.OpenApi/Reader/V2/OpenApiDocumentDeserializer.cs index f7cbe711a..369d03470 100644 --- a/src/Microsoft.OpenApi/Reader/V2/OpenApiDocumentDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V2/OpenApiDocumentDeserializer.cs @@ -117,7 +117,7 @@ internal static partial class OpenApiV2Deserializer {s => s.StartsWith(OpenApiConstants.ExtensionFieldNamePrefix, StringComparison.OrdinalIgnoreCase), (o, p, n, _) => o.AddExtension(p, LoadExtension(p, n))} }; - private static void MakeServers(IList servers, ParsingContext context, RootNode rootNode) + private static void MakeServers(List servers, ParsingContext context, RootNode rootNode) { var host = context.GetFromTempStorage("host"); var basePath = context.GetFromTempStorage("basePath"); @@ -148,7 +148,7 @@ private static void MakeServers(IList servers, ParsingContext con { host = host ?? defaultUrl.GetComponents(UriComponents.NormalizedHost, UriFormat.SafeUnescaped); basePath = basePath ?? defaultUrl.GetComponents(UriComponents.Path, UriFormat.SafeUnescaped); - schemes = schemes ?? new List { defaultUrl.GetComponents(UriComponents.Scheme, UriFormat.SafeUnescaped) }; + schemes = schemes ?? [defaultUrl.GetComponents(UriComponents.Scheme, UriFormat.SafeUnescaped)]; } else if (String.IsNullOrEmpty(host) && String.IsNullOrEmpty(basePath)) { @@ -250,7 +250,7 @@ public static OpenApiDocument LoadOpenApi(RootNode rootNode) // Post Process OpenApi Object if (openApiDoc.Servers == null) { - openApiDoc.Servers = new List(); + openApiDoc.Servers = []; } MakeServers(openApiDoc.Servers, openApiNode.Context, rootNode); @@ -310,8 +310,8 @@ private static bool IsHostValid(string host) internal class RequestBodyReferenceFixer : OpenApiVisitorBase { - private readonly IDictionary _requestBodies; - public RequestBodyReferenceFixer(IDictionary requestBodies) + private readonly Dictionary _requestBodies; + public RequestBodyReferenceFixer(Dictionary requestBodies) { _requestBodies = requestBodies; } diff --git a/src/Microsoft.OpenApi/Reader/V2/OpenApiOperationDeserializer.cs b/src/Microsoft.OpenApi/Reader/V2/OpenApiOperationDeserializer.cs index 4bd28a18d..4e53273e8 100644 --- a/src/Microsoft.OpenApi/Reader/V2/OpenApiOperationDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V2/OpenApiOperationDeserializer.cs @@ -10,6 +10,7 @@ using Microsoft.OpenApi.Models.References; using Microsoft.OpenApi.Models.Interfaces; using System; +using Microsoft.OpenApi.Interfaces; namespace Microsoft.OpenApi.Reader.V2 { @@ -195,7 +196,7 @@ private static OpenApiRequestBody CreateFormBody(ParsingContext context, List>(TempStorageKeys.OperationConsumes) ?? context.GetFromTempStorage>(TempStorageKeys.GlobalConsumes) ?? - new List { "application/x-www-form-urlencoded" }; + ["application/x-www-form-urlencoded"]; var formBody = new OpenApiRequestBody { @@ -222,7 +223,7 @@ internal static IOpenApiRequestBody CreateRequestBody( { var consumes = context.GetFromTempStorage>(TempStorageKeys.OperationConsumes) ?? context.GetFromTempStorage>(TempStorageKeys.GlobalConsumes) ?? - new List { "application/json" }; + ["application/json"]; var requestBody = new OpenApiRequestBody { @@ -238,8 +239,9 @@ internal static IOpenApiRequestBody CreateRequestBody( Extensions = bodyParameter.Extensions }; - if (requestBody.Extensions is not null && bodyParameter.Name is not null) + if (bodyParameter.Name is not null) { + requestBody.Extensions ??= []; requestBody.Extensions[OpenApiConstants.BodyName] = new OpenApiAny(bodyParameter.Name); } return requestBody; diff --git a/src/Microsoft.OpenApi/Reader/V2/OpenApiResponseDeserializer.cs b/src/Microsoft.OpenApi/Reader/V2/OpenApiResponseDeserializer.cs index 653208578..3560a3258 100644 --- a/src/Microsoft.OpenApi/Reader/V2/OpenApiResponseDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V2/OpenApiResponseDeserializer.cs @@ -62,7 +62,7 @@ private static void ProcessProduces(MapNode mapNode, OpenApiResponse response, P { if (response.Content == null) { - response.Content = new Dictionary(); + response.Content = []; } else if (context.GetFromTempStorage(TempStorageKeys.ResponseProducesSet, response)) { @@ -72,11 +72,10 @@ private static void ProcessProduces(MapNode mapNode, OpenApiResponse response, P var produces = context.GetFromTempStorage>(TempStorageKeys.OperationProduces) ?? context.GetFromTempStorage>(TempStorageKeys.GlobalProduces) - ?? context.DefaultContentType ?? new List { "application/octet-stream" }; + ?? context.DefaultContentType ?? ["application/octet-stream"]; var schema = context.GetFromTempStorage(TempStorageKeys.ResponseSchema, response); - var examples = context.GetFromTempStorage>(TempStorageKeys.Examples, response) - ?? new Dictionary(); + var examples = context.GetFromTempStorage>(TempStorageKeys.Examples, response); foreach (var produce in produces) { diff --git a/src/Microsoft.OpenApi/Reader/V31/OpenApiSchemaDeserializer.cs b/src/Microsoft.OpenApi/Reader/V31/OpenApiSchemaDeserializer.cs index 020472c7a..71265aa8c 100644 --- a/src/Microsoft.OpenApi/Reader/V31/OpenApiSchemaDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V31/OpenApiSchemaDeserializer.cs @@ -10,6 +10,7 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; +using System.Text.Json.Nodes; namespace Microsoft.OpenApi.Reader.V31 { @@ -382,8 +383,9 @@ public static IOpenApiSchema LoadSchema(ParseNode node, OpenApiDocument hostDocu { propertyNode.ParseField(schema, _openApiSchemaFixedFields, _openApiSchemaPatternFields, hostDocument); } - else if (schema.UnrecognizedKeywords is not null && propertyNode.JsonNode is not null) + else if (propertyNode.JsonNode is not null) { + schema.UnrecognizedKeywords ??= new Dictionary(StringComparer.Ordinal); schema.UnrecognizedKeywords[propertyNode.Name] = propertyNode.JsonNode; } } diff --git a/src/Microsoft.OpenApi/Reader/V31/OpenApiV31VersionService.cs b/src/Microsoft.OpenApi/Reader/V31/OpenApiV31VersionService.cs index 3e010be9b..da404f4c0 100644 --- a/src/Microsoft.OpenApi/Reader/V31/OpenApiV31VersionService.cs +++ b/src/Microsoft.OpenApi/Reader/V31/OpenApiV31VersionService.cs @@ -29,7 +29,7 @@ public OpenApiV31VersionService(OpenApiDiagnostic diagnostic) Diagnostic = diagnostic; } - private readonly IDictionary> _loaders = new Dictionary> + private readonly Dictionary> _loaders = new Dictionary> { [typeof(OpenApiAny)] = OpenApiV31Deserializer.LoadAny, [typeof(OpenApiCallback)] = OpenApiV31Deserializer.LoadCallback, diff --git a/src/Microsoft.OpenApi/Services/CopyReferences.cs b/src/Microsoft.OpenApi/Services/CopyReferences.cs index 6874b3f8d..96932490d 100644 --- a/src/Microsoft.OpenApi/Services/CopyReferences.cs +++ b/src/Microsoft.OpenApi/Services/CopyReferences.cs @@ -89,8 +89,9 @@ private void AddSchemaToComponents(IOpenApiSchema? schema, string? referenceId = { EnsureComponentsExist(); EnsureSchemasExist(); - if (Components.Schemas is not null && referenceId is not null && schema is not null && !Components.Schemas.ContainsKey(referenceId)) + if (referenceId is not null && schema is not null && !(Components.Schemas?.ContainsKey(referenceId) ?? false)) { + Components.Schemas ??= []; Components.Schemas.Add(referenceId, schema); } } @@ -99,8 +100,9 @@ private void AddParameterToComponents(IOpenApiParameter? parameter, string? refe { EnsureComponentsExist(); EnsureParametersExist(); - if (Components.Parameters is not null && parameter is not null && referenceId is not null && !Components.Parameters.ContainsKey(referenceId)) + if (parameter is not null && referenceId is not null && !(Components.Parameters?.ContainsKey(referenceId) ?? false)) { + Components.Parameters ??= []; Components.Parameters.Add(referenceId, parameter); } } @@ -109,8 +111,9 @@ private void AddResponseToComponents(IOpenApiResponse? response, string? referen { EnsureComponentsExist(); EnsureResponsesExist(); - if (Components.Responses is not null && referenceId is not null && response is not null && !Components.Responses.ContainsKey(referenceId)) + if (referenceId is not null && response is not null && !(Components.Responses?.ContainsKey(referenceId) ?? false)) { + Components.Responses ??= []; Components.Responses.Add(referenceId, response); } } @@ -118,8 +121,9 @@ private void AddRequestBodyToComponents(IOpenApiRequestBody? requestBody, string { EnsureComponentsExist(); EnsureRequestBodiesExist(); - if (Components.RequestBodies is not null && requestBody is not null && referenceId is not null && !Components.RequestBodies.ContainsKey(referenceId)) + if (requestBody is not null && referenceId is not null && !(Components.RequestBodies?.ContainsKey(referenceId) ?? false)) { + Components.RequestBodies ??= []; Components.RequestBodies.Add(referenceId, requestBody); } } @@ -127,8 +131,9 @@ private void AddLinkToComponents(IOpenApiLink? link, string? referenceId = null) { EnsureComponentsExist(); EnsureLinksExist(); - if (Components.Links is not null && link is not null && referenceId is not null && !Components.Links.ContainsKey(referenceId)) + if (link is not null && referenceId is not null && !(Components.Links?.ContainsKey(referenceId) ?? false)) { + Components.Links ??= []; Components.Links.Add(referenceId, link); } } @@ -136,8 +141,9 @@ private void AddCallbackToComponents(IOpenApiCallback? callback, string? referen { EnsureComponentsExist(); EnsureCallbacksExist(); - if (Components.Callbacks is not null && callback is not null && referenceId is not null && !Components.Callbacks.ContainsKey(referenceId)) + if (callback is not null && referenceId is not null && !(Components.Callbacks?.ContainsKey(referenceId) ?? false)) { + Components.Callbacks ??= []; Components.Callbacks.Add(referenceId, callback); } } @@ -145,8 +151,9 @@ private void AddHeaderToComponents(IOpenApiHeader? header, string? referenceId = { EnsureComponentsExist(); EnsureHeadersExist(); - if (Components.Headers is not null && header is not null && referenceId is not null && !Components.Headers.ContainsKey(referenceId)) + if (header is not null && referenceId is not null && !(Components.Headers?.ContainsKey(referenceId) ?? false)) { + Components.Headers ??= []; Components.Headers.Add(referenceId, header); } } @@ -154,8 +161,9 @@ private void AddExampleToComponents(IOpenApiExample? example, string? referenceI { EnsureComponentsExist(); EnsureExamplesExist(); - if (Components.Examples is not null && example is not null && referenceId is not null && !Components.Examples.ContainsKey(referenceId)) + if (example is not null && referenceId is not null && !(Components.Examples?.ContainsKey(referenceId) ?? false)) { + Components.Examples ??= []; Components.Examples.Add(referenceId, example); } } @@ -163,8 +171,9 @@ private void AddPathItemToComponents(IOpenApiPathItem? pathItem, string? referen { EnsureComponentsExist(); EnsurePathItemsExist(); - if (Components.PathItems is not null && pathItem is not null && referenceId is not null && !Components.PathItems.ContainsKey(referenceId)) + if (pathItem is not null && referenceId is not null && !(Components.PathItems?.ContainsKey(referenceId) ?? false)) { + Components.PathItems ??= []; Components.PathItems.Add(referenceId, pathItem); } } @@ -172,8 +181,9 @@ private void AddSecuritySchemeToComponents(IOpenApiSecurityScheme? securitySchem { EnsureComponentsExist(); EnsureSecuritySchemesExist(); - if (Components.SecuritySchemes is not null && securityScheme is not null && referenceId is not null && !Components.SecuritySchemes.ContainsKey(referenceId)) + if (securityScheme is not null && referenceId is not null && !(Components.SecuritySchemes?.ContainsKey(referenceId) ?? false)) { + Components.SecuritySchemes ??= []; Components.SecuritySchemes.Add(referenceId, securityScheme); } } @@ -198,7 +208,7 @@ private void EnsureSchemasExist() { if (_target.Components is not null) { - _target.Components.Schemas ??= new Dictionary(); + _target.Components.Schemas ??= []; } } @@ -206,7 +216,7 @@ private void EnsureParametersExist() { if (_target.Components is not null) { - _target.Components.Parameters ??= new Dictionary(); + _target.Components.Parameters ??= []; } } @@ -214,7 +224,7 @@ private void EnsureResponsesExist() { if (_target.Components is not null) { - _target.Components.Responses ??= new Dictionary(); + _target.Components.Responses ??= []; } } @@ -222,7 +232,7 @@ private void EnsureRequestBodiesExist() { if (_target.Components is not null) { - _target.Components.RequestBodies ??= new Dictionary(); + _target.Components.RequestBodies ??= []; } } @@ -230,7 +240,7 @@ private void EnsureExamplesExist() { if (_target.Components is not null) { - _target.Components.Examples ??= new Dictionary(); + _target.Components.Examples ??= []; } } @@ -238,7 +248,7 @@ private void EnsureHeadersExist() { if (_target.Components is not null) { - _target.Components.Headers ??= new Dictionary(); + _target.Components.Headers ??= []; } } @@ -246,7 +256,7 @@ private void EnsureCallbacksExist() { if (_target.Components is not null) { - _target.Components.Callbacks ??= new Dictionary(); + _target.Components.Callbacks ??= []; } } @@ -254,7 +264,7 @@ private void EnsureLinksExist() { if (_target.Components is not null) { - _target.Components.Links ??= new Dictionary(); + _target.Components.Links ??= []; } } @@ -262,14 +272,14 @@ private void EnsureSecuritySchemesExist() { if (_target.Components is not null) { - _target.Components.SecuritySchemes ??= new Dictionary(); + _target.Components.SecuritySchemes ??= []; } } private void EnsurePathItemsExist() { if (_target.Components is not null) { - _target.Components.PathItems = new Dictionary(); + _target.Components.PathItems = []; } } } diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs index 82a09c249..f58053b1c 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs @@ -109,17 +109,19 @@ public static OpenApiDocument CreateFilteredDocument(OpenApiDocument source, Fun } } - if (result.CurrentKeys?.Operation != null && result.Operation != null) + if (result.CurrentKeys?.Operation != null && result.Operation != null && pathItem is OpenApiPathItem openApiPathItem) { - pathItem?.Operations?.Add(result.CurrentKeys.Operation, result.Operation); + openApiPathItem.Operations ??= []; + openApiPathItem.Operations?.Add(result.CurrentKeys.Operation, result.Operation); if (result.Parameters?.Any() ?? false) { + openApiPathItem.Parameters ??= []; foreach (var parameter in result.Parameters) { - if (pathItem?.Parameters is not null && !pathItem.Parameters.Contains(parameter)) + if (openApiPathItem?.Parameters is not null && !openApiPathItem.Parameters.Contains(parameter)) { - pathItem.Parameters.Add(parameter); + openApiPathItem.Parameters.Add(parameter); } } } @@ -151,7 +153,7 @@ public static OpenApiUrlTreeNode CreateOpenApiUrlTreeNode(Dictionary? GetOpenApiOperations(OpenApiUrlTreeNode rootNode, string relativeUrl, string label) + private static Dictionary? GetOpenApiOperations(OpenApiUrlTreeNode rootNode, string relativeUrl, string label) { if (relativeUrl.Equals("/", StringComparison.Ordinal) && rootNode.HasOperations(label)) { @@ -160,7 +162,7 @@ public static OpenApiUrlTreeNode CreateOpenApiUrlTreeNode(Dictionary? operations = null; + Dictionary? operations = null; var targetChild = rootNode; @@ -228,7 +230,7 @@ public static OpenApiUrlTreeNode CreateOpenApiUrlTreeNode(Dictionary FindOperations(OpenApiDocument sourceDocument, Func predicate) + private static List FindOperations(OpenApiDocument sourceDocument, Func predicate) { var search = new OperationSearch(predicate); var walker = new OpenApiWalker(search); @@ -260,7 +262,7 @@ private static bool AddReferences(OpenApiComponents newComponents, OpenApiCompon if (target?.Schemas is not null && !target.Schemas.ContainsKey(item.Key)) { moreStuff = true; - target.Schemas.Add(item); + target.Schemas.Add(item.Key, item.Value); } } } @@ -272,7 +274,7 @@ private static bool AddReferences(OpenApiComponents newComponents, OpenApiCompon if (target?.Parameters is not null && !target.Parameters.ContainsKey(item.Key)) { moreStuff = true; - target.Parameters.Add(item); + target.Parameters.Add(item.Key, item.Value); } } } @@ -284,7 +286,7 @@ private static bool AddReferences(OpenApiComponents newComponents, OpenApiCompon if (target?.Responses is not null && !target.Responses.ContainsKey(item.Key)) { moreStuff = true; - target.Responses.Add(item); + target.Responses.Add(item.Key, item.Value); } } } @@ -295,7 +297,7 @@ private static bool AddReferences(OpenApiComponents newComponents, OpenApiCompon .Where(item => target?.RequestBodies is not null && !target.RequestBodies.ContainsKey(item.Key))) { moreStuff = true; - target?.RequestBodies?.Add(item); + target?.RequestBodies?.Add(item.Key, item.Value); } } @@ -305,7 +307,7 @@ private static bool AddReferences(OpenApiComponents newComponents, OpenApiCompon .Where(item => target?.Headers is not null && !target.Headers.ContainsKey(item.Key))) { moreStuff = true; - target?.Headers?.Add(item); + target?.Headers?.Add(item.Key, item.Value); } } @@ -315,7 +317,7 @@ private static bool AddReferences(OpenApiComponents newComponents, OpenApiCompon .Where(item => target?.Links is not null && !target.Links.ContainsKey(item.Key))) { moreStuff = true; - target?.Links?.Add(item); + target?.Links?.Add(item.Key, item.Value); } } @@ -325,7 +327,7 @@ private static bool AddReferences(OpenApiComponents newComponents, OpenApiCompon .Where(item => target?.Callbacks is not null && !target.Callbacks.ContainsKey(item.Key))) { moreStuff = true; - target?.Callbacks?.Add(item); + target?.Callbacks?.Add(item.Key, item.Value); } } @@ -335,7 +337,7 @@ private static bool AddReferences(OpenApiComponents newComponents, OpenApiCompon .Where(item => target?.Examples is not null && !target.Examples.ContainsKey(item.Key))) { moreStuff = true; - target?.Examples?.Add(item); + target?.Examples?.Add(item.Key, item.Value); } } @@ -345,14 +347,14 @@ private static bool AddReferences(OpenApiComponents newComponents, OpenApiCompon .Where(item => target?.SecuritySchemes is not null && !target.SecuritySchemes.ContainsKey(item.Key))) { moreStuff = true; - target?.SecuritySchemes?.Add(item); + target?.SecuritySchemes?.Add(item.Key, item.Value); } } return moreStuff; } - private static string ExtractPath(string url, IList? serverList) + private static string ExtractPath(string url, List? serverList) { // if OpenAPI has servers, then see if the url matches one of them var baseUrl = serverList?.Select(s => s.Url?.TrimEnd('/')) @@ -363,7 +365,7 @@ private static string ExtractPath(string url, IList? serverList) : url.Split(new[] { baseUrl }, StringSplitOptions.None)[1]; } - private static void ValidateFilters(IDictionary>? requestUrls, string? operationIds, string? tags) + private static void ValidateFilters(Dictionary>? requestUrls, string? operationIds, string? tags) { if (requestUrls != null && (operationIds != null || tags != null)) { @@ -438,7 +440,7 @@ private static Func GetRequestUrlsPr return (path, operationType, _) => operationTypes.Contains(operationType + path); } - private static List GetOperationTypes(IDictionary openApiOperations, List url, string path) + private static List GetOperationTypes(Dictionary openApiOperations, List url, string path) { // Add the available ops if they are in the postman collection. See path.Value return openApiOperations.Where(ops => url.Contains(ops.Key.ToString().ToUpper())) diff --git a/src/Microsoft.OpenApi/Services/OpenApiUrlTreeNode.cs b/src/Microsoft.OpenApi/Services/OpenApiUrlTreeNode.cs index ab1a33e0b..5e4029c4d 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiUrlTreeNode.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiUrlTreeNode.cs @@ -21,7 +21,7 @@ public class OpenApiUrlTreeNode /// /// All the subdirectories of a node. /// - public IDictionary Children { get; } = new Dictionary(); + public Dictionary Children { get; } = new Dictionary(); /// /// The relative directory path of the current node from the root node. @@ -31,12 +31,12 @@ public class OpenApiUrlTreeNode /// /// Dictionary of labels and Path Item objects that describe the operations available on a node. /// - public IDictionary PathItems { get; } = new Dictionary(); + public Dictionary PathItems { get; } = new Dictionary(); /// /// A dictionary of key value pairs that contain information about a node. /// - public IDictionary> AdditionalData { get; set; } = new Dictionary>(); + public Dictionary> AdditionalData { get; set; } = new Dictionary>(); /// /// Flag indicating whether a node segment is a path parameter. diff --git a/src/Microsoft.OpenApi/Services/OpenApiVisitorBase.cs b/src/Microsoft.OpenApi/Services/OpenApiVisitorBase.cs index aae8527d7..3f6cb1a92 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiVisitorBase.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiVisitorBase.cs @@ -86,7 +86,7 @@ public virtual void Visit(OpenApiLicense license) /// /// Visits list of /// - public virtual void Visit(IList servers) + public virtual void Visit(List servers) { } @@ -107,7 +107,7 @@ public virtual void Visit(OpenApiPaths paths) /// /// Visits Webhooks> /// - public virtual void Visit(IDictionary webhooks) + public virtual void Visit(Dictionary webhooks) { } @@ -128,7 +128,7 @@ public virtual void Visit(OpenApiServerVariable serverVariable) /// /// Visits the operations. /// - public virtual void Visit(IDictionary operations) + public virtual void Visit(Dictionary operations) { } @@ -142,7 +142,7 @@ public virtual void Visit(OpenApiOperation operation) /// /// Visits list of /// - public virtual void Visit(IList parameters) + public virtual void Visit(List parameters) { } @@ -163,14 +163,14 @@ public virtual void Visit(IOpenApiRequestBody requestBody) /// /// Visits headers. /// - public virtual void Visit(IDictionary headers) + public virtual void Visit(Dictionary headers) { } /// /// Visits callbacks. /// - public virtual void Visit(IDictionary callbacks) + public virtual void Visit(Dictionary callbacks) { } @@ -191,7 +191,7 @@ public virtual void Visit(OpenApiResponses response) /// /// Visits media type content. /// - public virtual void Visit(IDictionary content) + public virtual void Visit(Dictionary content) { } @@ -212,7 +212,7 @@ public virtual void Visit(OpenApiEncoding encoding) /// /// Visits the examples. /// - public virtual void Visit(IDictionary examples) + public virtual void Visit(Dictionary examples) { } @@ -240,7 +240,7 @@ public virtual void Visit(IOpenApiSchema schema) /// /// Visits the links. /// - public virtual void Visit(IDictionary links) + public virtual void Visit(Dictionary links) { } @@ -310,21 +310,21 @@ public virtual void Visit(IOpenApiExample example) /// /// Visits list of /// - public virtual void Visit(ISet openApiTags) + public virtual void Visit(HashSet openApiTags) { } /// /// Visits list of /// - public virtual void Visit(ISet openApiTags) + public virtual void Visit(HashSet openApiTags) { } /// /// Visits list of /// - public virtual void Visit(IList openApiSecurityRequirements) + public virtual void Visit(List openApiSecurityRequirements) { } @@ -345,14 +345,14 @@ public virtual void Visit(IOpenApiExtension openApiExtension) /// /// Visits list of /// - public virtual void Visit(IList example) + public virtual void Visit(List example) { } /// /// Visits a dictionary of server variables /// - public virtual void Visit(IDictionary serverVariables) + public virtual void Visit(Dictionary serverVariables) { } @@ -360,7 +360,7 @@ public virtual void Visit(IDictionary serverVaria /// Visits a dictionary of encodings /// /// - public virtual void Visit(IDictionary encodings) + public virtual void Visit(Dictionary encodings) { } diff --git a/src/Microsoft.OpenApi/Services/OpenApiWalker.cs b/src/Microsoft.OpenApi/Services/OpenApiWalker.cs index 49ac98079..c0cc15979 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiWalker.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiWalker.cs @@ -62,7 +62,7 @@ public void Walk(OpenApiDocument? doc) /// /// Visits list of and child objects /// - internal void Walk(ISet? tags) + internal void Walk(HashSet? tags) { if (tags == null) { @@ -85,7 +85,7 @@ internal void Walk(ISet? tags) /// /// Visits list of and child objects /// - internal void Walk(ISet? tags) + internal void Walk(HashSet? tags) { if (tags == null) { @@ -283,7 +283,7 @@ internal void Walk(OpenApiPaths paths) /// /// Visits Webhooks and child objects /// - internal void Walk(IDictionary? webhooks) + internal void Walk(Dictionary? webhooks) { if (webhooks == null) { @@ -307,7 +307,7 @@ internal void Walk(IDictionary? webhooks) /// /// Visits list of and child objects /// - internal void Walk(IList? servers) + internal void Walk(List? servers) { if (servers == null) { @@ -489,7 +489,7 @@ internal void Walk(OpenApiServer? server) /// /// Visits dictionary of /// - internal void Walk(IDictionary? serverVariables) + internal void Walk(Dictionary? serverVariables) { if (serverVariables == null) { @@ -566,7 +566,7 @@ internal void Walk(IOpenApiPathItem pathItem, bool isComponent = false) /// /// Visits dictionary of /// - internal void Walk(IDictionary? operations) + internal void Walk(Dictionary? operations) { if (operations == null) { @@ -610,7 +610,7 @@ internal void Walk(OpenApiOperation operation) /// /// Visits list of /// - internal void Walk(IList? securityRequirements) + internal void Walk(List? securityRequirements) { if (securityRequirements == null) { @@ -631,7 +631,7 @@ internal void Walk(IList? securityRequirements) /// /// Visits list of /// - internal void Walk(IList? parameters) + internal void Walk(List? parameters) { if (parameters == null) { @@ -748,7 +748,7 @@ internal void Walk(IOpenApiRequestBody? requestBody, bool isComponent = false) /// /// Visits dictionary of /// - internal void Walk(IDictionary? headers) + internal void Walk(Dictionary? headers) { if (headers == null) { @@ -770,7 +770,7 @@ internal void Walk(IDictionary? headers) /// /// Visits dictionary of /// - internal void Walk(IDictionary? callbacks) + internal void Walk(Dictionary? callbacks) { if (callbacks == null) { @@ -792,7 +792,7 @@ internal void Walk(IDictionary? callbacks) /// /// Visits dictionary of /// - internal void Walk(IDictionary? content) + internal void Walk(Dictionary? content) { if (content == null) { @@ -832,7 +832,7 @@ internal void Walk(OpenApiMediaType mediaType) /// /// Visits dictionary of /// - internal void Walk(IDictionary? encodings) + internal void Walk(Dictionary? encodings) { if (encodings == null) { @@ -944,7 +944,7 @@ internal void Walk(IOpenApiSchema? schema, bool isComponent = false) /// /// Visits dictionary of /// - internal void Walk(IDictionary? examples) + internal void Walk(Dictionary? examples) { if (examples == null) { @@ -1000,7 +1000,7 @@ internal void Walk(IOpenApiExample example, bool isComponent = false) /// /// Visits the list of and child objects /// - internal void Walk(IList examples) + internal void Walk(List examples) { if (examples == null) { @@ -1022,7 +1022,7 @@ internal void Walk(IList examples) /// /// Visits a list of and child objects /// - internal void Walk(IList schemas) + internal void Walk(List schemas) { if (schemas == null) { @@ -1069,7 +1069,7 @@ internal void Walk(OpenApiOAuthFlow oAuthFlow) /// /// Visits dictionary of and child objects /// - internal void Walk(IDictionary? links) + internal void Walk(Dictionary? links) { if (links == null) { @@ -1202,11 +1202,11 @@ internal void Walk(IOpenApiElement element) case IOpenApiCallback e: Walk(e); break; case OpenApiEncoding e: Walk(e); break; case IOpenApiExample e: Walk(e); break; - case IDictionary e: Walk(e); break; + case Dictionary e: Walk(e); break; case OpenApiExternalDocs e: Walk(e); break; case OpenApiHeader e: Walk(e); break; case OpenApiLink e: Walk(e); break; - case IDictionary e: Walk(e); break; + case Dictionary e: Walk(e); break; case OpenApiMediaType e: Walk(e); break; case OpenApiOAuthFlows e: Walk(e); break; case OpenApiOAuthFlow e: Walk(e); break; @@ -1221,7 +1221,7 @@ internal void Walk(IOpenApiElement element) case OpenApiServer e: Walk(e); break; case OpenApiServerVariable e: Walk(e); break; case OpenApiTag e: Walk(e); break; - case ISet e: Walk(e); break; + case HashSet e: Walk(e); break; case IOpenApiExtensible e: Walk(e); break; case IOpenApiExtension e: Walk(e); break; } diff --git a/src/Microsoft.OpenApi/Services/OperationSearch.cs b/src/Microsoft.OpenApi/Services/OperationSearch.cs index ff2de5d2d..53e23f9af 100644 --- a/src/Microsoft.OpenApi/Services/OperationSearch.cs +++ b/src/Microsoft.OpenApi/Services/OperationSearch.cs @@ -21,7 +21,7 @@ public class OperationSearch : OpenApiVisitorBase /// /// A list of operations from the operation search. /// - public IList SearchResults => _searchResults; + public List SearchResults => _searchResults; /// /// The OperationSearch constructor. @@ -59,7 +59,7 @@ public override void Visit(IOpenApiPathItem pathItem) /// Visits list of . /// /// The target list of . - public override void Visit(IList parameters) + public override void Visit(List parameters) { /* The Parameter.Explode property should be true * if Parameter.Style == Form; but OData query params diff --git a/src/Microsoft.OpenApi/Services/SearchResult.cs b/src/Microsoft.OpenApi/Services/SearchResult.cs index 2fea9e03d..32e999e98 100644 --- a/src/Microsoft.OpenApi/Services/SearchResult.cs +++ b/src/Microsoft.OpenApi/Services/SearchResult.cs @@ -25,6 +25,6 @@ public class SearchResult /// /// Parameters object /// - public IList? Parameters { get; set; } + public List? Parameters { get; set; } } } diff --git a/src/Microsoft.OpenApi/Validations/OpenApiValidator.cs b/src/Microsoft.OpenApi/Validations/OpenApiValidator.cs index 54bd92deb..850d23635 100644 --- a/src/Microsoft.OpenApi/Validations/OpenApiValidator.cs +++ b/src/Microsoft.OpenApi/Validations/OpenApiValidator.cs @@ -18,8 +18,8 @@ namespace Microsoft.OpenApi.Validations public class OpenApiValidator : OpenApiVisitorBase, IValidationContext { private readonly ValidationRuleSet _ruleSet; - private readonly IList _errors = new List(); - private readonly IList _warnings = new List(); + private readonly List _errors = []; + private readonly List _warnings = []; /// /// Create a visitor that will validate an OpenAPIDocument @@ -120,7 +120,7 @@ public void AddWarning(OpenApiValidatorWarning warning) public override void Visit(IOpenApiExtension openApiExtension) => Validate(openApiExtension, openApiExtension.GetType()); /// - public override void Visit(IList example) => Validate(example, example.GetType()); + public override void Visit(List example) => Validate(example, example.GetType()); /// public override void Visit(IOpenApiPathItem pathItem) => Validate(pathItem); @@ -149,21 +149,21 @@ public void AddWarning(OpenApiValidatorWarning warning) /// public override void Visit(OpenApiOperation operation) => Validate(operation); /// - public override void Visit(IDictionary operations) => Validate(operations, operations.GetType()); + public override void Visit(Dictionary operations) => Validate(operations, operations.GetType()); /// - public override void Visit(IDictionary headers) => Validate(headers, headers.GetType()); + public override void Visit(Dictionary headers) => Validate(headers, headers.GetType()); /// - public override void Visit(IDictionary callbacks) => Validate(callbacks, callbacks.GetType()); + public override void Visit(Dictionary callbacks) => Validate(callbacks, callbacks.GetType()); /// - public override void Visit(IDictionary content) => Validate(content, content.GetType()); + public override void Visit(Dictionary content) => Validate(content, content.GetType()); /// - public override void Visit(IDictionary examples) => Validate(examples, examples.GetType()); + public override void Visit(Dictionary examples) => Validate(examples, examples.GetType()); /// - public override void Visit(IDictionary links) => Validate(links, links.GetType()); + public override void Visit(Dictionary links) => Validate(links, links.GetType()); /// - public override void Visit(IDictionary serverVariables) => Validate(serverVariables, serverVariables.GetType()); + public override void Visit(Dictionary serverVariables) => Validate(serverVariables, serverVariables.GetType()); /// - public override void Visit(IDictionary encodings) => Validate(encodings, encodings.GetType()); + public override void Visit(Dictionary encodings) => Validate(encodings, encodings.GetType()); private void Validate(T item) { diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiContactRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiContactRules.cs index e31dc1e07..ba8713910 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiContactRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiContactRules.cs @@ -21,13 +21,10 @@ public static class OpenApiContactRules (context, item) => { context.Enter("email"); - if (item is {Email: not null}) + if (item is {Email: not null} && !item.Email.IsEmailAddress()) { - if (!item.Email.IsEmailAddress()) - { - context.CreateError(nameof(EmailMustBeEmailFormat), - String.Format(SRResource.Validation_StringMustBeEmailAddress, item.Email)); - } + context.CreateError(nameof(EmailMustBeEmailFormat), + String.Format(SRResource.Validation_StringMustBeEmailAddress, item.Email)); } context.Exit(); }); diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiExtensionRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiExtensionRules.cs index 9853acb37..eba253df6 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiExtensionRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiExtensionRules.cs @@ -29,9 +29,9 @@ public static class OpenApiExtensibleRules { context.CreateError(nameof(ExtensionNameMustStartWithXDash), string.Format(SRResource.Validation_ExtensionNameMustBeginWithXDash, extensible, context.PathString)); - } - context.Exit(); - } + } + } + context.Exit(); }); } } diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiNonDefaultRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiNonDefaultRules.cs index 70dc7396a..34d84b796 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiNonDefaultRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiNonDefaultRules.cs @@ -90,7 +90,7 @@ public static class OpenApiNonDefaultRules private static void ValidateMismatchedDataType(IValidationContext context, string ruleName, JsonNode? example, - IDictionary? examples, + Dictionary? examples, IOpenApiSchema? schema) { // example diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiSchemaRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiSchemaRules.cs index 9884d54dd..808124f01 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiSchemaRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiSchemaRules.cs @@ -50,7 +50,7 @@ public static bool ValidateChildSchemaAgainstDiscriminator(IOpenApiSchema schema { if (discriminatorName is not null) { - if (!schema.Required?.Contains(discriminatorName) ?? false) + if (schema.Required is null || !schema.Required.Contains(discriminatorName)) { // recursively check nested schema.OneOf, schema.AnyOf or schema.AllOf and their required fields for the discriminator if (schema.OneOf?.Count != 0) @@ -83,7 +83,7 @@ public static bool ValidateChildSchemaAgainstDiscriminator(IOpenApiSchema schema /// between other schemas which may satisfy the payload description. /// The child schema. /// - public static bool TraverseSchemaElements(string discriminatorName, IList? childSchema) + public static bool TraverseSchemaElements(string discriminatorName, List? childSchema) { if (childSchema is not null) { diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiServerRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiServerRules.cs index d4ffc5429..375485058 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiServerRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiServerRules.cs @@ -36,9 +36,9 @@ public static class OpenApiServerRules context.Enter(variable.Key); ValidateServerVariableRequiredFields(context, variable.Key, variable.Value); context.Exit(); - } - context.Exit(); - } + } + } + context.Exit(); }); // add more rules diff --git a/src/Microsoft.OpenApi/Validations/Rules/RuleHelpers.cs b/src/Microsoft.OpenApi/Validations/Rules/RuleHelpers.cs index 1b4896d3a..a19ba82c7 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/RuleHelpers.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/RuleHelpers.cs @@ -85,13 +85,13 @@ public static void ValidateDataTypeMismatch( return; } - foreach (var kvp in anyObject) + foreach (var key in from kvp in anyObject + let key = kvp.Key + select key) { - var key = kvp.Key; context.Enter(key); - if (schema.Properties != null && - schema.Properties.TryGetValue(key, out var property)) + schema.Properties.TryGetValue(key, out var property)) { ValidateDataTypeMismatch(context, ruleName, anyObject[key], property); } diff --git a/src/Microsoft.OpenApi/Validations/ValidationRuleSet.cs b/src/Microsoft.OpenApi/Validations/ValidationRuleSet.cs index d09d9b566..943b88e6b 100644 --- a/src/Microsoft.OpenApi/Validations/ValidationRuleSet.cs +++ b/src/Microsoft.OpenApi/Validations/ValidationRuleSet.cs @@ -16,7 +16,7 @@ namespace Microsoft.OpenApi.Validations /// public sealed class ValidationRuleSet { - private Dictionary> _rulesDictionary = new(); + private Dictionary> _rulesDictionary = new(); private static ValidationRuleSet? _defaultRuleSet; @@ -26,7 +26,7 @@ public sealed class ValidationRuleSet /// /// Gets the rules in this rule set. /// - public IList Rules => _rulesDictionary.Values.SelectMany(v => v).ToList(); + public List Rules => _rulesDictionary.Values.SelectMany(v => v).ToList(); /// /// Gets the number of elements contained in this rule set. @@ -45,7 +45,7 @@ public ValidationRuleSet() /// /// The type that is to be validated /// Either the rules related to the type, or an empty list. - public IList FindRules(Type type) + public List FindRules(Type type) { _rulesDictionary.TryGetValue(type, out var results); return results ?? _emptyRules; @@ -85,7 +85,7 @@ public static ValidationRuleSet GetEmptyRuleSet() /// The rule set to add validation rules to. /// The validation rules to be added to the rules set. /// Throws a null argument exception if the arguments are null. - public static void AddValidationRules(ValidationRuleSet ruleSet, IDictionary> rules) + public static void AddValidationRules(ValidationRuleSet ruleSet, Dictionary> rules) { if (ruleSet == null || rules == null) { @@ -119,7 +119,7 @@ public ValidationRuleSet(ValidationRuleSet ruleSet) /// Initializes a new instance of the class. /// /// Rules to be contained in this ruleset. - public ValidationRuleSet(IDictionary> rules) + public ValidationRuleSet(Dictionary> rules) { if (rules == null) { @@ -137,7 +137,7 @@ public ValidationRuleSet(IDictionary> rules) /// /// The key for the rule. /// The list of rules. - public void Add(Type key, IList rules) + public void Add(Type key, List rules) { foreach (var rule in rules) { @@ -155,7 +155,7 @@ public void Add(Type key, ValidationRule rule) { if (!_rulesDictionary.ContainsKey(key)) { - _rulesDictionary[key] = new List(); + _rulesDictionary[key] = []; } if (_rulesDictionary[key].Contains(rule)) @@ -199,7 +199,7 @@ public bool Remove(Type key) /// Name of the rule. public void Remove(string ruleName) { - foreach (KeyValuePair> rule in _rulesDictionary) + foreach (KeyValuePair> rule in _rulesDictionary) { _rulesDictionary[rule.Key] = rule.Value.Where(vr => !vr.Name.Equals(ruleName, StringComparison.Ordinal)).ToList(); } @@ -216,7 +216,7 @@ public void Remove(string ruleName) /// true if the rule is successfully removed; otherwise, false. public bool Remove(Type key, ValidationRule rule) { - if (_rulesDictionary.TryGetValue(key, out IList? validationRules)) + if (_rulesDictionary.TryGetValue(key, out List? validationRules)) { return validationRules.Remove(rule); } @@ -260,7 +260,7 @@ public bool ContainsKey(Type key) /// public bool Contains(Type key, ValidationRule rule) { - return _rulesDictionary.TryGetValue(key, out IList? validationRules) && validationRules.Contains(rule); + return _rulesDictionary.TryGetValue(key, out List? validationRules) && validationRules.Contains(rule); } /// @@ -271,7 +271,7 @@ public bool Contains(Type key, ValidationRule rule) /// key is found; otherwise, an empty object. /// This parameter is passed uninitialized. /// true if the specified key has rules. - public bool TryGetValue(Type key, out IList? rules) + public bool TryGetValue(Type key, out List? rules) { return _rulesDictionary.TryGetValue(key, out rules); } diff --git a/src/Microsoft.OpenApi/Writers/OpenApiWriterAnyExtensions.cs b/src/Microsoft.OpenApi/Writers/OpenApiWriterAnyExtensions.cs index eee8068a9..222d7a24e 100644 --- a/src/Microsoft.OpenApi/Writers/OpenApiWriterAnyExtensions.cs +++ b/src/Microsoft.OpenApi/Writers/OpenApiWriterAnyExtensions.cs @@ -22,7 +22,7 @@ public static class OpenApiWriterAnyExtensions /// The Open API writer. /// The specification extensions. /// Version of the OpenAPI specification that that will be output. - public static void WriteExtensions(this IOpenApiWriter writer, IDictionary? extensions, OpenApiSpecVersion specVersion) + public static void WriteExtensions(this IOpenApiWriter writer, Dictionary? extensions, OpenApiSpecVersion specVersion) { Utils.CheckArgumentNull(writer); diff --git a/src/Microsoft.OpenApi/Writers/OpenApiWriterExtensions.cs b/src/Microsoft.OpenApi/Writers/OpenApiWriterExtensions.cs index 3df27f6d7..31f60d0fd 100644 --- a/src/Microsoft.OpenApi/Writers/OpenApiWriterExtensions.cs +++ b/src/Microsoft.OpenApi/Writers/OpenApiWriterExtensions.cs @@ -246,7 +246,7 @@ public static void WriteRequiredCollection( public static void WriteRequiredMap( this IOpenApiWriter writer, string name, - IDictionary? elements, + Dictionary? elements, Action action) { writer.WriteMapInternal(name, elements, action); @@ -262,7 +262,7 @@ public static void WriteRequiredMap( public static void WriteOptionalMap( this IOpenApiWriter writer, string name, - IDictionary? elements, + Dictionary? elements, Action action) { if (elements != null && elements.Any()) @@ -281,7 +281,7 @@ public static void WriteOptionalMap( public static void WriteOptionalMap( this IOpenApiWriter writer, string name, - IDictionary? elements, + Dictionary? elements, Action action) { if (elements != null && elements.Any()) @@ -300,7 +300,7 @@ public static void WriteOptionalMap( public static void WriteOptionalMap( this IOpenApiWriter writer, string name, - IDictionary? elements, + Dictionary? elements, Action action) { if (elements != null && elements.Any()) @@ -319,8 +319,8 @@ public static void WriteOptionalMap( public static void WriteOptionalMap( this IOpenApiWriter writer, string name, - IDictionary>? elements, - Action> action) + Dictionary>? elements, + Action> action) { if (elements != null && elements.Any()) { @@ -339,7 +339,7 @@ public static void WriteOptionalMap( public static void WriteOptionalMap( this IOpenApiWriter writer, string name, - IDictionary? elements, + Dictionary? elements, Action action) where T : IOpenApiElement { @@ -360,7 +360,7 @@ public static void WriteOptionalMap( public static void WriteOptionalMap( this IOpenApiWriter writer, string name, - IDictionary? elements, + Dictionary? elements, Action action) where T : IOpenApiElement { @@ -381,7 +381,7 @@ public static void WriteOptionalMap( public static void WriteRequiredMap( this IOpenApiWriter writer, string name, - IDictionary? elements, + Dictionary? elements, Action action) where T : IOpenApiElement { @@ -419,7 +419,7 @@ private static void WriteCollectionInternal( private static void WriteMapInternal( this IOpenApiWriter writer, string name, - IDictionary? elements, + Dictionary? elements, Action action) { WriteMapInternal(writer, name, elements, (w, _, s) => action(w, s)); @@ -428,7 +428,7 @@ private static void WriteMapInternal( private static void WriteMapInternal( this IOpenApiWriter writer, string name, - IDictionary? elements, + Dictionary? elements, Action action) { Utils.CheckArgumentNull(action); diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Formatters/PowerShellFormatterTests.cs b/test/Microsoft.OpenApi.Hidi.Tests/Formatters/PowerShellFormatterTests.cs index 92cfae013..7b3cd338e 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Formatters/PowerShellFormatterTests.cs +++ b/test/Microsoft.OpenApi.Hidi.Tests/Formatters/PowerShellFormatterTests.cs @@ -32,11 +32,11 @@ public void FormatOperationIdsInOpenAPIDocument(string operationId, string expec var openApiDocument = new OpenApiDocument { Info = new() { Title = "Test", Version = "1.0" }, - Servers = new List { new() { Url = "https://localhost/" } }, + Servers = [new() { Url = "https://localhost/" }], Paths = new() { { path, new OpenApiPathItem() { - Operations = new Dictionary + Operations = new() { { operationType, new() { OperationId = operationId } } } @@ -96,7 +96,7 @@ public void ResolveFunctionParameters() var walker = new OpenApiWalker(powerShellFormatter); walker.Walk(openApiDocument); - var idsParameter = openApiDocument.Paths["/foo"].Operations?[HttpMethod.Get].Parameters?.Where(static p => p.Name == "ids").FirstOrDefault(); + var idsParameter = openApiDocument.Paths["/foo"].Operations?[HttpMethod.Get].Parameters?.FirstOrDefault(static p => p.Name == "ids"); // Assert Assert.Null(idsParameter?.Content); @@ -109,11 +109,11 @@ private static OpenApiDocument GetSampleOpenApiDocument() return new() { Info = new() { Title = "Test", Version = "1.0" }, - Servers = new List { new() { Url = "https://localhost/" } }, + Servers = [new() { Url = "https://localhost/" }], Paths = new() { { "/foo", new OpenApiPathItem() { - Operations = new Dictionary + Operations = new() { { HttpMethod.Get, new() @@ -125,7 +125,7 @@ private static OpenApiDocument GetSampleOpenApiDocument() { Name = "ids", In = ParameterLocation.Query, - Content = new Dictionary + Content = new() { { "application/json", @@ -144,7 +144,7 @@ private static OpenApiDocument GetSampleOpenApiDocument() } } ], - Extensions = new Dictionary + Extensions = new() { { "x-ms-docs-operation-type", new OpenApiAny("function") @@ -158,32 +158,32 @@ private static OpenApiDocument GetSampleOpenApiDocument() }, Components = new() { - Schemas = new Dictionary + Schemas = new() { { "TestSchema", new OpenApiSchema { Type = JsonSchemaType.Object, - Properties = new Dictionary + Properties = new() { { "averageAudioDegradation", new OpenApiSchema { - AnyOf = new List - { + AnyOf = + [ new OpenApiSchema() { Type = JsonSchemaType.Number | JsonSchemaType.Null }, new OpenApiSchema() { Type = JsonSchemaType.String } - }, + ], Format = "float", } }, { "defaultPrice", new OpenApiSchema { - OneOf = new List - { + OneOf = + [ new OpenApiSchema() { Type = JsonSchemaType.Number, Format = "double" }, new OpenApiSchema() { Type = JsonSchemaType.String } - } + ] } } } diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs index 7702c56c1..e617d3b3c 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs +++ b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs @@ -79,11 +79,11 @@ public void TestPredicateFiltersUsingRelativeRequestUrls() var openApiDocument = new OpenApiDocument { Info = new() { Title = "Test", Version = "1.0" }, - Servers = new List { new() { Url = "https://localhost/" } }, + Servers = [new() { Url = "https://localhost/" }], Paths = new() { {"/foo", new OpenApiPathItem() { - Operations = new Dictionary + Operations = new() { { HttpMethod.Get, new() }, { HttpMethod.Patch, new() }, @@ -97,7 +97,7 @@ public void TestPredicateFiltersUsingRelativeRequestUrls() // Given a set of RequestUrls var requestUrls = new Dictionary> { - {"/foo", new List {"GET","POST"}} + {"/foo", ["GET","POST"]} }; // When @@ -116,12 +116,12 @@ public void CreateFilteredDocumentUsingPredicateFromRequestUrl() var openApiDocument = new OpenApiDocument { Info = new() { Title = "Test", Version = "1.0" }, - Servers = new List { new() { Url = "https://localhost/" } }, + Servers = [new() { Url = "https://localhost/" }], Paths = new() { ["/test/{id}"] = new OpenApiPathItem() { - Operations = new Dictionary + Operations = new() { { HttpMethod.Get, new() }, { HttpMethod.Patch, new() } @@ -147,7 +147,7 @@ public void CreateFilteredDocumentUsingPredicateFromRequestUrl() var requestUrls = new Dictionary> { - {"/test/{id}", new List {"GET","PATCH"}} + {"/test/{id}",["GET","PATCH"]} }; // Act @@ -302,7 +302,7 @@ public void ReturnsPathParametersOnSlicingBasedOnOperationIdsOrTags(string? oper // Assert foreach (var pathItem in subsetOpenApiDocument.Paths) { - Assert.True(pathItem.Value.Parameters!.Any()); + Assert.True(pathItem.Value.Parameters!.Count != 0); Assert.Single(pathItem.Value.Parameters!); } } diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs index f39e87c69..7e5b4de3c 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs +++ b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs @@ -45,7 +45,7 @@ public void CreateFilteredDocumentOnMinimalOpenApi() { ["/test"] = new OpenApiPathItem() { - Operations = new Dictionary + Operations = new() { [HttpMethod.Get] = new OpenApiOperation() } diff --git a/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/OpenApiDocumentMock.cs b/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/OpenApiDocumentMock.cs index 71768bfbe..421cecdd7 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/OpenApiDocumentMock.cs +++ b/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/OpenApiDocumentMock.cs @@ -40,18 +40,18 @@ public static OpenApiDocument CreateOpenApiDocument() Title = "People", Version = "v1.0" }, - Servers = new List - { + Servers = + [ new() { Url = "https://graph.microsoft.com/v1.0" } - }, + ], Paths = new() { ["/"] = new OpenApiPathItem() // root path { - Operations = new Dictionary + Operations = new() { { HttpMethod.Get, new OpenApiOperation @@ -72,35 +72,33 @@ public static OpenApiDocument CreateOpenApiDocument() }, [getTeamsActivityByPeriodPath] = new OpenApiPathItem() { - Operations = new Dictionary + Operations = new() { { HttpMethod.Get, new OpenApiOperation { OperationId = "reports.getTeamsUserActivityCounts", Summary = "Invoke function getTeamsUserActivityUserCounts", - Parameters = new List - { + Parameters = + [ + new OpenApiParameter() { - new OpenApiParameter() + Name = "period", + In = ParameterLocation.Path, + Required = true, + Schema = new OpenApiSchema() { - Name = "period", - In = ParameterLocation.Path, - Required = true, - Schema = new OpenApiSchema() - { - Type = JsonSchemaType.String - } + Type = JsonSchemaType.String } } - }, + ], Responses = new() { { "200", new OpenApiResponse() { Description = "Success", - Content = new Dictionary + Content = new() { { applicationJsonMediaType, @@ -119,53 +117,49 @@ public static OpenApiDocument CreateOpenApiDocument() } } }, - Parameters = new List - { + Parameters = + [ + new OpenApiParameter() { - new OpenApiParameter() + Name = "period", + In = ParameterLocation.Path, + Required = true, + Schema = new OpenApiSchema() { - Name = "period", - In = ParameterLocation.Path, - Required = true, - Schema = new OpenApiSchema() - { - Type = JsonSchemaType.String - } + Type = JsonSchemaType.String } } - } + ] }, [getTeamsActivityByDatePath] = new OpenApiPathItem() { - Operations = new Dictionary + Operations = new() { { HttpMethod.Get, new OpenApiOperation { OperationId = "reports.getTeamsUserActivityUserDetail-a3f1", Summary = "Invoke function getTeamsUserActivityUserDetail", - Parameters = new List - { + Parameters = + [ + new OpenApiParameter() { - new OpenApiParameter() + Name = "period", + In = ParameterLocation.Path, + Required = true, + Schema = new OpenApiSchema() { - Name = "period", - In = ParameterLocation.Path, - Required = true, - Schema = new OpenApiSchema() - { - Type = JsonSchemaType.String - } + Type = JsonSchemaType.String } } - }, + ], Responses = new() { { "200", new OpenApiResponse() { Description = "Success", - Content = new Dictionary + Content = new() { { applicationJsonMediaType, @@ -184,8 +178,8 @@ public static OpenApiDocument CreateOpenApiDocument() } } }, - Parameters = new List - { + Parameters = + [ new OpenApiParameter() { Name = "period", @@ -196,11 +190,11 @@ public static OpenApiDocument CreateOpenApiDocument() Type = JsonSchemaType.String } } - } + ] }, [usersPath] = new OpenApiPathItem() { - Operations = new Dictionary + Operations = new() { { HttpMethod.Get, new OpenApiOperation @@ -213,7 +207,7 @@ public static OpenApiDocument CreateOpenApiDocument() "200", new OpenApiResponse() { Description = "Retrieved entities", - Content = new Dictionary + Content = new() { { applicationJsonMediaType, @@ -223,7 +217,7 @@ public static OpenApiDocument CreateOpenApiDocument() { Title = "Collection of user", Type = JsonSchemaType.Object, - Properties = new Dictionary + Properties = new() { { "value", @@ -246,7 +240,7 @@ public static OpenApiDocument CreateOpenApiDocument() }, [usersByIdPath] = new OpenApiPathItem() { - Operations = new Dictionary + Operations = new() { { HttpMethod.Get, new OpenApiOperation @@ -259,7 +253,7 @@ public static OpenApiDocument CreateOpenApiDocument() "200", new OpenApiResponse() { Description = "Retrieved entity", - Content = new Dictionary + Content = new() { { applicationJsonMediaType, @@ -293,7 +287,7 @@ public static OpenApiDocument CreateOpenApiDocument() }, [messagesByIdPath] = new OpenApiPathItem() { - Operations = new Dictionary + Operations = new() { { HttpMethod.Get, new OpenApiOperation @@ -301,8 +295,8 @@ public static OpenApiDocument CreateOpenApiDocument() OperationId = "users.GetMessages", Summary = "Get messages from users", Description = "The messages in a mailbox or folder. Read-only. Nullable.", - Parameters = new List - { + Parameters = + [ new OpenApiParameter() { Name = "$select", @@ -315,14 +309,14 @@ public static OpenApiDocument CreateOpenApiDocument() } // missing explode parameter } - }, + ], Responses = new() { { "200", new OpenApiResponse() { Description = "Retrieved navigation property", - Content = new Dictionary + Content = new() { { applicationJsonMediaType, @@ -340,7 +334,7 @@ public static OpenApiDocument CreateOpenApiDocument() }, [administrativeUnitRestorePath] = new OpenApiPathItem() { - Operations = new Dictionary + Operations = new() { { HttpMethod.Post, new OpenApiOperation @@ -369,7 +363,7 @@ public static OpenApiDocument CreateOpenApiDocument() "200", new OpenApiResponse() { Description = "Success", - Content = new Dictionary + Content = new() { { applicationJsonMediaType, @@ -391,7 +385,7 @@ public static OpenApiDocument CreateOpenApiDocument() }, [logoPath] = new OpenApiPathItem() { - Operations = new Dictionary + Operations = new() { { HttpMethod.Put, new OpenApiOperation @@ -413,7 +407,7 @@ public static OpenApiDocument CreateOpenApiDocument() }, [securityProfilesPath] = new OpenApiPathItem() { - Operations = new Dictionary + Operations = new() { { HttpMethod.Get, new OpenApiOperation @@ -426,7 +420,7 @@ public static OpenApiDocument CreateOpenApiDocument() "200", new OpenApiResponse() { Description = "Retrieved navigation property", - Content = new Dictionary + Content = new() { { applicationJsonMediaType, @@ -436,7 +430,7 @@ public static OpenApiDocument CreateOpenApiDocument() { Title = "Collection of hostSecurityProfile", Type = JsonSchemaType.Object, - Properties = new Dictionary + Properties = new() { { "value", @@ -459,15 +453,15 @@ public static OpenApiDocument CreateOpenApiDocument() }, [communicationsCallsKeepAlivePath] = new OpenApiPathItem() { - Operations = new Dictionary + Operations = new() { { HttpMethod.Post, new OpenApiOperation { OperationId = "communications.calls.call.keepAlive", Summary = "Invoke action keepAlive", - Parameters = new List - { + Parameters = + [ new OpenApiParameter() { Name = "call-id", @@ -478,14 +472,14 @@ public static OpenApiDocument CreateOpenApiDocument() { Type = JsonSchemaType.String }, - Extensions = new Dictionary + Extensions = new() { { "x-ms-docs-key-type", new OpenApiAny("call") } } } - }, + ], Responses = new() { { @@ -495,7 +489,7 @@ public static OpenApiDocument CreateOpenApiDocument() } } }, - Extensions = new Dictionary + Extensions = new() { { "x-ms-docs-operation-type", new OpenApiAny("action") @@ -507,15 +501,15 @@ public static OpenApiDocument CreateOpenApiDocument() }, [eventsDeltaPath] = new OpenApiPathItem() { - Operations = new Dictionary + Operations = new() { { HttpMethod.Get, new OpenApiOperation { OperationId = "groups.group.events.event.calendar.events.delta", Summary = "Invoke function delta", - Parameters = new List - { + Parameters = + [ new OpenApiParameter() { Name = "group-id", @@ -526,7 +520,7 @@ public static OpenApiDocument CreateOpenApiDocument() { Type = JsonSchemaType.String }, - Extensions = new Dictionary + Extensions = new() { { "x-ms-docs-key-type", new OpenApiAny("group") @@ -543,21 +537,21 @@ public static OpenApiDocument CreateOpenApiDocument() { Type = JsonSchemaType.String }, - Extensions = new Dictionary + Extensions = new() { { "x-ms-docs-key-type", new OpenApiAny("event") } } } - }, + ], Responses = new() { { "200", new OpenApiResponse() { Description = "Success", - Content = new Dictionary + Content = new() { { applicationJsonMediaType, @@ -565,7 +559,7 @@ public static OpenApiDocument CreateOpenApiDocument() { Schema = new OpenApiSchema() { - Properties = new Dictionary + Properties = new() { { "value", @@ -582,7 +576,7 @@ public static OpenApiDocument CreateOpenApiDocument() } } }, - Extensions = new Dictionary + Extensions = new() { { "x-ms-docs-operation-type", new OpenApiAny("function") @@ -594,7 +588,7 @@ public static OpenApiDocument CreateOpenApiDocument() }, [refPath] = new OpenApiPathItem() { - Operations = new Dictionary + Operations = new() { { HttpMethod.Get, new OpenApiOperation @@ -608,14 +602,14 @@ public static OpenApiDocument CreateOpenApiDocument() }, Components = new() { - Schemas = new Dictionary + Schemas = new() { { "microsoft.graph.networkInterface", new OpenApiSchema { Title = "networkInterface", Type = JsonSchemaType.Object, - Properties = new Dictionary + Properties = new() { { "description", new OpenApiSchema diff --git a/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/TryLoadReferenceV2Tests.cs b/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/TryLoadReferenceV2Tests.cs index d32c9b46b..4336a29f8 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/TryLoadReferenceV2Tests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/TryLoadReferenceV2Tests.cs @@ -72,7 +72,7 @@ public async Task LoadResponseReference() new OpenApiResponse { Description = "Entity not found.", - Content = new Dictionary + Content = new() { ["application/json"] = new() } @@ -89,7 +89,7 @@ public async Task LoadResponseAndSchemaReference() var expected = new OpenApiResponse { Description = "General Error", - Content = + Content = new() { ["application/json"] = new() { diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs index 6bf41959c..d6daa59d8 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs @@ -76,7 +76,7 @@ public async Task ShouldParseProducesInAnyOrder() var okSchema = new OpenApiSchema { - Properties = new Dictionary + Properties = new() { { "id", new OpenApiSchema { @@ -89,7 +89,7 @@ public async Task ShouldParseProducesInAnyOrder() var errorSchema = new OpenApiSchema { - Properties = new Dictionary + Properties = new() { { "code", new OpenApiSchema { @@ -132,17 +132,17 @@ public async Task ShouldParseProducesInAnyOrder() Version = "1.0.0" }, Servers = - { + [ new OpenApiServer { Url = "https://" } - }, + ], Paths = new() { ["/items"] = new OpenApiPathItem() { - Operations = + Operations = new() { [HttpMethod.Get] = new() { @@ -151,7 +151,7 @@ public async Task ShouldParseProducesInAnyOrder() ["200"] = new OpenApiResponse() { Description = "An OK response", - Content = + Content = new() { ["application/json"] = okMediaType, ["application/xml"] = okMediaType, @@ -160,7 +160,7 @@ public async Task ShouldParseProducesInAnyOrder() ["default"] = new OpenApiResponse() { Description = "An error response", - Content = + Content = new() { ["application/json"] = errorMediaType, ["application/xml"] = errorMediaType @@ -175,7 +175,7 @@ public async Task ShouldParseProducesInAnyOrder() ["200"] = new OpenApiResponse() { Description = "An OK response", - Content = + Content = new() { ["html/text"] = okMediaType } @@ -183,7 +183,7 @@ public async Task ShouldParseProducesInAnyOrder() ["default"] = new OpenApiResponse() { Description = "An error response", - Content = + Content = new() { ["html/text"] = errorMediaType } @@ -197,7 +197,7 @@ public async Task ShouldParseProducesInAnyOrder() ["200"] = new OpenApiResponse() { Description = "An OK response", - Content = + Content = new() { ["application/json"] = okMediaType, ["application/xml"] = okMediaType, @@ -206,7 +206,7 @@ public async Task ShouldParseProducesInAnyOrder() ["default"] = new OpenApiResponse() { Description = "An error response", - Content = + Content = new() { ["application/json"] = errorMediaType, ["application/xml"] = errorMediaType @@ -219,7 +219,7 @@ public async Task ShouldParseProducesInAnyOrder() }, Components = new() { - Schemas = + Schemas = new() { ["Item"] = okSchema, ["Error"] = errorSchema diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiHeaderTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiHeaderTests.cs index 1b1187a42..86ebfcab2 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiHeaderTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiHeaderTests.cs @@ -68,11 +68,11 @@ public void ParseHeaderWithEnumShouldSucceed() Type = JsonSchemaType.Number, Format = "float", Enum = - { + [ new OpenApiAny(7).Node, new OpenApiAny(8).Node, new OpenApiAny(9).Node - } + ] } }, options => options.IgnoringCyclicReferences() .Excluding((IMemberInfo memberInfo) => diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs index cd62c27be..3d40535c6 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs @@ -10,6 +10,7 @@ using FluentAssertions; using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Extensions; +using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.Interfaces; using Microsoft.OpenApi.Models.References; @@ -51,7 +52,7 @@ public class OpenApiOperationTests ["200"] = new OpenApiResponse { Description = "Pet updated.", - Content = new Dictionary + Content = new() { ["application/json"] = new OpenApiMediaType(), ["application/xml"] = new OpenApiMediaType() @@ -83,7 +84,7 @@ public class OpenApiOperationTests { Description = "Pet to update with", Required = true, - Content = + Content = new() { ["application/json"] = new OpenApiMediaType { @@ -93,7 +94,8 @@ public class OpenApiOperationTests } } }, - Extensions = { + Extensions = new() + { [OpenApiConstants.BodyName] = new OpenApiAny("petObject") } }, @@ -102,7 +104,7 @@ public class OpenApiOperationTests ["200"] = new OpenApiResponse { Description = "Pet updated.", - Content = new Dictionary + Content = new() { ["application/json"] = new OpenApiMediaType(), ["application/xml"] = new OpenApiMediaType() @@ -111,7 +113,7 @@ public class OpenApiOperationTests ["405"] = new OpenApiResponse { Description = "Invalid input", - Content = new Dictionary + Content = new() { ["application/json"] = new OpenApiMediaType(), ["application/xml"] = new OpenApiMediaType() @@ -213,7 +215,7 @@ public void ParseOperationWithResponseExamplesShouldSucceed() { "200", new OpenApiResponse() { Description = "An array of float response", - Content = + Content = new() { ["application/json"] = new OpenApiMediaType() { @@ -524,7 +526,7 @@ public async Task SerializesBodyReferencesWorks() }; openApiDocument.Paths.Add("/users", new OpenApiPathItem { - Operations = new Dictionary + Operations = new() { [HttpMethod.Post] = operation } @@ -532,7 +534,7 @@ public async Task SerializesBodyReferencesWorks() openApiDocument.AddComponent("UserRequest", new OpenApiRequestBody { Description = "User creation request body", - Content = + Content = new() { ["application/json"] = new OpenApiMediaType { @@ -543,7 +545,7 @@ public async Task SerializesBodyReferencesWorks() openApiDocument.AddComponent("UserSchema", new OpenApiSchema { Type = JsonSchemaType.Object, - Properties = + Properties = new Dictionary { ["name"] = new OpenApiSchema { @@ -624,7 +626,7 @@ public void DeduplicatesTagReferences() Description = "", OperationId = "loginUser", Parameters = - { + [ new OpenApiParameter { Name = "password", @@ -636,7 +638,7 @@ public void DeduplicatesTagReferences() Type = JsonSchemaType.String } } - } + ] }; using var textWriter = new StringWriter(); var writer = new OpenApiJsonWriter(textWriter); diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiParameterTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiParameterTests.cs index b20c27761..6e8685c4b 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiParameterTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiParameterTests.cs @@ -267,11 +267,11 @@ public void ParseParameterWithEnumShouldSucceed() Type = JsonSchemaType.Number, Format = "float", Enum = - { - new OpenApiAny(7).Node, - new OpenApiAny(8).Node, - new OpenApiAny(9).Node - } + [ + new OpenApiAny(7).Node, + new OpenApiAny(8).Node, + new OpenApiAny(9).Node + ] } }; diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiPathItemTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiPathItemTests.cs index b3ebdc3dc..7079b4b5a 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiPathItemTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiPathItemTests.cs @@ -7,8 +7,10 @@ using System.Linq; using System.Net.Http; using Microsoft.OpenApi.Models; +using Microsoft.OpenApi.Models.Interfaces; using Microsoft.OpenApi.Reader.ParseNodes; using Microsoft.OpenApi.Reader.V2; +using Microsoft.OpenApi.Writers; using Xunit; namespace Microsoft.OpenApi.Readers.Tests.V2Tests @@ -39,7 +41,7 @@ public class OpenApiPathItemTests Style = ParameterStyle.Simple } ], - Operations = + Operations = new() { [HttpMethod.Put] = new() { @@ -62,14 +64,14 @@ public class OpenApiPathItemTests ], RequestBody = new OpenApiRequestBody() { - Content = + Content = new() { ["application/x-www-form-urlencoded"] = new() { Schema = new OpenApiSchema() { Type = JsonSchemaType.Object, - Properties = + Properties = new() { ["name"] = new OpenApiSchema() { @@ -93,7 +95,7 @@ public class OpenApiPathItemTests Schema = new OpenApiSchema() { Type = JsonSchemaType.Object, - Properties = + Properties = new() { ["name"] = new OpenApiSchema() { @@ -119,7 +121,7 @@ public class OpenApiPathItemTests ["200"] = new OpenApiResponse() { Description = "Pet updated.", - Content = new Dictionary + Content = new() { ["application/json"] = new(), ["application/xml"] = new() @@ -128,7 +130,7 @@ public class OpenApiPathItemTests ["405"] = new OpenApiResponse() { Description = "Invalid input", - Content = new Dictionary + Content = new() { ["application/json"] = new(), ["application/xml"] = new() @@ -168,14 +170,14 @@ public class OpenApiPathItemTests ], RequestBody = new OpenApiRequestBody() { - Content = + Content = new() { ["application/x-www-form-urlencoded"] = new() { Schema = new OpenApiSchema() { Type = JsonSchemaType.Object, - Properties = + Properties = new() { ["name"] = new OpenApiSchema() { @@ -204,7 +206,7 @@ public class OpenApiPathItemTests Schema = new OpenApiSchema() { Type = JsonSchemaType.Object, - Properties = + Properties = new() { ["name"] = new OpenApiSchema() { @@ -222,10 +224,10 @@ public class OpenApiPathItemTests Type = JsonSchemaType.String } }, - Required = new HashSet - { + Required = + [ "name" - } + ] } } } @@ -235,7 +237,7 @@ public class OpenApiPathItemTests ["200"] = new OpenApiResponse() { Description = "Pet updated.", - Content = new Dictionary + Content = new() { ["application/json"] = new(), ["application/xml"] = new() diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSchemaTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSchemaTests.cs index 781b272e1..68f41271a 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSchemaTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSchemaTests.cs @@ -85,12 +85,12 @@ public void ParseSchemaWithEnumShouldSucceed() { Type = JsonSchemaType.Number, Format = "float", - Enum = new List - { + Enum = + [ new OpenApiAny(7).Node, new OpenApiAny(8).Node, new OpenApiAny(9).Node - } + ] }; schema.Should().BeEquivalentTo(expected, options => @@ -109,7 +109,7 @@ public void PropertiesReferenceShouldWork() var targetSchema = new OpenApiSchema() { Type = JsonSchemaType.Object, - Properties = new Dictionary + Properties = new() { ["prop1"] = new OpenApiSchema() { @@ -117,12 +117,15 @@ public void PropertiesReferenceShouldWork() } } }; - workingDocument.Components.Schemas.Add(referenceId, targetSchema); + workingDocument.Components.Schemas = new() + { + [referenceId] = targetSchema + }; workingDocument.Workspace.RegisterComponents(workingDocument); var referenceSchema = new OpenApiSchema() { Type = JsonSchemaType.Object, - Properties = new Dictionary + Properties = new() { ["propA"] = new OpenApiSchemaReference(referenceId, workingDocument), } diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSecuritySchemeTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSecuritySchemeTests.cs index bdac6ac26..86d7943fb 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSecuritySchemeTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSecuritySchemeTests.cs @@ -2,8 +2,8 @@ // Licensed under the MIT license. using System; +using System.Collections.Generic; using System.IO; -using System.Linq; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Reader; using Microsoft.OpenApi.Reader.ParseNodes; @@ -95,7 +95,7 @@ public void ParseOAuth2ImplicitSecuritySchemeShouldSucceed() Implicit = new() { AuthorizationUrl = new("http://swagger.io/api/oauth/dialog"), - Scopes = + Scopes = new Dictionary { ["write:pets"] = "modify pets in your account", ["read:pets"] = "read your pets" @@ -130,7 +130,7 @@ public void ParseOAuth2PasswordSecuritySchemeShouldSucceed() Password = new OpenApiOAuthFlow { AuthorizationUrl = new Uri("http://swagger.io/api/oauth/dialog"), - Scopes = + Scopes = new Dictionary { ["write:pets"] = "modify pets in your account", ["read:pets"] = "read your pets" @@ -165,7 +165,7 @@ public void ParseOAuth2ApplicationSecuritySchemeShouldSucceed() ClientCredentials = new OpenApiOAuthFlow { AuthorizationUrl = new Uri("http://swagger.io/api/oauth/dialog"), - Scopes = + Scopes = new Dictionary { ["write:pets"] = "modify pets in your account", ["read:pets"] = "read your pets" @@ -201,7 +201,7 @@ public void ParseOAuth2AccessCodeSecuritySchemeShouldSucceed() AuthorizationCode = new OpenApiOAuthFlow { AuthorizationUrl = new Uri("http://swagger.io/api/oauth/dialog"), - Scopes = + Scopes = new Dictionary { ["write:pets"] = "modify pets in your account", ["read:pets"] = "read your pets" @@ -216,7 +216,7 @@ static YamlDocument LoadYamlDocument(Stream input) using var reader = new StreamReader(input); var yamlStream = new YamlStream(); yamlStream.Load(reader); - return yamlStream.Documents.First(); + return yamlStream.Documents[0]; } } } diff --git a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentTests.cs index 167d59cc7..fa99dcd1b 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentTests.cs @@ -32,7 +32,7 @@ public async Task ParseDocumentWithWebhooksShouldSucceed() var components = new OpenApiComponents { - Schemas = + Schemas = new() { ["petSchema"] = new OpenApiSchema() { @@ -42,11 +42,11 @@ public async Task ParseDocumentWithWebhooksShouldSucceed() "id", "name" }, - DependentRequired = new Dictionary> + DependentRequired = new Dictionary> { { "tag", new HashSet { "category" } } }, - Properties = new Dictionary + Properties = new() { ["id"] = new OpenApiSchema() { @@ -74,11 +74,11 @@ public async Task ParseDocumentWithWebhooksShouldSucceed() { "name" }, - DependentRequired = new Dictionary> + DependentRequired = new Dictionary> { { "tag", new HashSet { "category" } } }, - Properties = new Dictionary + Properties = new() { ["id"] = new OpenApiSchema() { @@ -113,7 +113,7 @@ public async Task ParseDocumentWithWebhooksShouldSucceed() { ["pets"] = new OpenApiPathItem { - Operations = new Dictionary + Operations = new() { [HttpMethod.Get] = new OpenApiOperation { @@ -154,7 +154,7 @@ public async Task ParseDocumentWithWebhooksShouldSucceed() ["200"] = new OpenApiResponse { Description = "pet response", - Content = new Dictionary + Content = new() { ["application/json"] = new OpenApiMediaType { @@ -182,7 +182,7 @@ public async Task ParseDocumentWithWebhooksShouldSucceed() { Description = "Information about a new pet in the system", Required = true, - Content = new Dictionary + Content = new() { ["application/json"] = new OpenApiMediaType { @@ -195,7 +195,7 @@ public async Task ParseDocumentWithWebhooksShouldSucceed() ["200"] = new OpenApiResponse { Description = "Return a 200 status to indicate that the data was received successfully", - Content = new Dictionary + Content = new() { ["application/json"] = new OpenApiMediaType { @@ -224,7 +224,7 @@ public async Task ParseDocumentsWithReusablePathItemInWebhooksSucceeds() var components = new OpenApiComponents { - Schemas = new Dictionary + Schemas = new() { ["petSchema"] = new OpenApiSchema() { @@ -234,11 +234,11 @@ public async Task ParseDocumentsWithReusablePathItemInWebhooksSucceeds() "id", "name" }, - DependentRequired = new Dictionary> + DependentRequired = new Dictionary> { { "tag", new HashSet { "category" } } }, - Properties = new Dictionary + Properties = new() { ["id"] = new OpenApiSchema() { @@ -266,11 +266,11 @@ public async Task ParseDocumentsWithReusablePathItemInWebhooksSucceeds() { "name" }, - DependentRequired = new Dictionary> + DependentRequired = new Dictionary> { { "tag", new HashSet { "category" } } }, - Properties = new Dictionary + Properties = new() { ["id"] = new OpenApiSchema() { @@ -303,48 +303,48 @@ public async Task ParseDocumentsWithReusablePathItemInWebhooksSucceeds() { ["pets"] = new OpenApiPathItem { - Operations = new Dictionary + Operations = new() { [HttpMethod.Get] = new OpenApiOperation { Description = "Returns all pets from the system that the user has access to", OperationId = "findPets", Parameters = - [ - new OpenApiParameter + [ + new OpenApiParameter + { + Name = "tags", + In = ParameterLocation.Query, + Description = "tags to filter by", + Required = false, + Schema = new OpenApiSchema() { - Name = "tags", - In = ParameterLocation.Query, - Description = "tags to filter by", - Required = false, - Schema = new OpenApiSchema() + Type = JsonSchemaType.Array, + Items = new OpenApiSchema() { - Type = JsonSchemaType.Array, - Items = new OpenApiSchema() - { - Type = JsonSchemaType.String - } + Type = JsonSchemaType.String } - }, - new OpenApiParameter + } + }, + new OpenApiParameter + { + Name = "limit", + In = ParameterLocation.Query, + Description = "maximum number of results to return", + Required = false, + Schema = new OpenApiSchema() { - Name = "limit", - In = ParameterLocation.Query, - Description = "maximum number of results to return", - Required = false, - Schema = new OpenApiSchema() - { - Type = JsonSchemaType.Integer, - Format = "int32" - } + Type = JsonSchemaType.Integer, + Format = "int32" } - ], + } + ], Responses = new OpenApiResponses { ["200"] = new OpenApiResponse { Description = "pet response", - Content = new Dictionary + Content = new() { ["application/json"] = new OpenApiMediaType { @@ -372,7 +372,7 @@ public async Task ParseDocumentsWithReusablePathItemInWebhooksSucceeds() { Description = "Information about a new pet in the system", Required = true, - Content = new Dictionary + Content = new() { ["application/json"] = new OpenApiMediaType { @@ -385,7 +385,7 @@ public async Task ParseDocumentsWithReusablePathItemInWebhooksSucceeds() ["200"] = new OpenApiResponse { Description = "Return a 200 status to indicate that the data was received successfully", - Content = new Dictionary + Content = new() { ["application/json"] = new OpenApiMediaType { @@ -447,7 +447,7 @@ public async Task ParseDocumentWithPatternPropertiesInSchemaWorks() var expectedSchema = new OpenApiSchema { Type = JsonSchemaType.Object, - Properties = new Dictionary + Properties = new() { ["prop1"] = new OpenApiSchema { @@ -462,7 +462,7 @@ public async Task ParseDocumentWithPatternPropertiesInSchemaWorks() Type = JsonSchemaType.String } }, - PatternProperties = new Dictionary + PatternProperties = new() { ["^x-.*$"] = new OpenApiSchema { diff --git a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiSchemaTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiSchemaTests.cs index 838ecbff2..9ccb8d0ee 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiSchemaTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiSchemaTests.cs @@ -41,7 +41,7 @@ public async Task ParseBasicV31SchemaShouldSucceed() Schema = new Uri("https://json-schema.org/draft/2020-12/schema"), Description = "A representation of a person, company, organization, or place", Type = JsonSchemaType.Object, - Properties = new Dictionary + Properties = new() { ["fruits"] = new OpenApiSchema { @@ -66,11 +66,11 @@ public async Task ParseBasicV31SchemaShouldSucceed() "veggieName", "veggieLike" }, - DependentRequired = new Dictionary> + DependentRequired = new Dictionary> { { "veggieType", new HashSet { "veggieColor", "veggieSize" } } }, - Properties = new Dictionary + Properties = new() { ["veggieName"] = new OpenApiSchema { @@ -181,7 +181,7 @@ public async Task ParseV31SchemaShouldSucceed() var expectedSchema = new OpenApiSchema { Type = JsonSchemaType.Object, - Properties = new Dictionary + Properties = new() { ["one"] = new OpenApiSchema() { @@ -205,7 +205,7 @@ public async Task ParseAdvancedV31SchemaShouldSucceed() var expectedSchema = new OpenApiSchema { Type = JsonSchemaType.Object, - Properties = new Dictionary + Properties = new() { ["one"] = new OpenApiSchema() { diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiCallbackTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiCallbackTests.cs index 93b5677e7..2b131f263 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiCallbackTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiCallbackTests.cs @@ -1,12 +1,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. +using System.Collections.Generic; using System.IO; using System.Linq; using System.Net.Http; using System.Threading.Tasks; using Microsoft.OpenApi.Expressions; using Microsoft.OpenApi.Models; +using Microsoft.OpenApi.Models.Interfaces; using Microsoft.OpenApi.Models.References; using Microsoft.OpenApi.Reader; using Xunit; @@ -27,19 +29,19 @@ public async Task ParseBasicCallbackShouldSucceed() Assert.Equivalent( new OpenApiCallback { - PathItems = + PathItems = new Dictionary { [RuntimeExpression.Build("$request.body#/url")] = new OpenApiPathItem { - Operations = + Operations = new Dictionary { [HttpMethod.Post] = new OpenApiOperation { RequestBody = new OpenApiRequestBody { - Content = + Content = new Dictionary { ["application/json"] = null } @@ -81,12 +83,13 @@ public async Task ParseCallbackWithReferenceShouldSucceed() PathItems = { [RuntimeExpression.Build("$request.body#/url")]= new OpenApiPathItem { - Operations = { + Operations = new Dictionary + { [HttpMethod.Post] = new OpenApiOperation() { RequestBody = new OpenApiRequestBody { - Content = + Content = new Dictionary { ["application/json"] = new OpenApiMediaType { @@ -131,12 +134,13 @@ public async Task ParseMultipleCallbacksWithReferenceShouldSucceed() PathItems = { [RuntimeExpression.Build("$request.body#/url")]= new OpenApiPathItem { - Operations = { + Operations = new Dictionary + { [HttpMethod.Post] = new OpenApiOperation() { RequestBody = new OpenApiRequestBody { - Content = + Content = new Dictionary { ["application/json"] = new OpenApiMediaType { @@ -163,16 +167,17 @@ public async Task ParseMultipleCallbacksWithReferenceShouldSucceed() Assert.Equivalent( new OpenApiCallback { - PathItems = + PathItems = new Dictionary { [RuntimeExpression.Build("/simplePath")]= new OpenApiPathItem { - Operations = { + Operations = new Dictionary + { [HttpMethod.Post] = new OpenApiOperation() { RequestBody = new OpenApiRequestBody { Description = "Callback 2", - Content = + Content = new Dictionary { ["application/json"] = new OpenApiMediaType { @@ -199,15 +204,16 @@ public async Task ParseMultipleCallbacksWithReferenceShouldSucceed() Assert.Equivalent( new OpenApiCallback { - PathItems = + PathItems = new Dictionary { [RuntimeExpression.Build(@"http://example.com?transactionId={$request.body#/id}&email={$request.body#/email}")] = new OpenApiPathItem { - Operations = { + Operations = new Dictionary + { [HttpMethod.Post] = new OpenApiOperation() { RequestBody = new OpenApiRequestBody { - Content = + Content = new Dictionary { ["application/xml"] = new OpenApiMediaType { diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDiscriminatorTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDiscriminatorTests.cs index f1b047f08..f0eb50953 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDiscriminatorTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDiscriminatorTests.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. using System; +using System.Collections.Generic; using System.IO; using System.Threading.Tasks; using Microsoft.OpenApi.Models; @@ -35,8 +36,8 @@ public async Task ParseBasicDiscriminatorShouldSucceed() new OpenApiDiscriminator { PropertyName = "pet_type", - Mapping = - { + Mapping = new Dictionary + { ["puppy"] = new OpenApiSchemaReference("Dog", openApiDocument), ["kitten"] = new OpenApiSchemaReference("Cat" , openApiDocument, "https://gigantic-server.com/schemas/animals.json"), ["monster"] = new OpenApiSchemaReference("schema.json" , openApiDocument, "https://gigantic-server.com/schemas/Monster/schema.json") diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs index bc17c02fb..d6b393404 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs @@ -112,7 +112,7 @@ public async Task ParseBasicDocumentWithMultipleServersShouldSucceed() Version = "0.9.1", }, Servers = - { + [ new OpenApiServer { Url = new Uri("http://www.example.org/api").ToString(), @@ -123,7 +123,7 @@ public async Task ParseBasicDocumentWithMultipleServersShouldSucceed() Url = new Uri("https://www.example.org/api").ToString(), Description = "The https endpoint" } - }, + ], Paths = new OpenApiPaths() }, options => options.Excluding(x => x.Workspace).Excluding(y => y.BaseUri)); } @@ -190,7 +190,7 @@ public async Task ParseStandardPetStoreDocumentShouldSucceed() var components = new OpenApiComponents { - Schemas = new Dictionary + Schemas = new() { ["pet1"] = new OpenApiSchema() { @@ -200,7 +200,7 @@ public async Task ParseStandardPetStoreDocumentShouldSucceed() "id", "name" }, - Properties = new Dictionary + Properties = new() { ["id"] = new OpenApiSchema() { @@ -224,7 +224,7 @@ public async Task ParseStandardPetStoreDocumentShouldSucceed() { "name" }, - Properties = new Dictionary + Properties = new() { ["id"] = new OpenApiSchema() { @@ -249,7 +249,7 @@ public async Task ParseStandardPetStoreDocumentShouldSucceed() "code", "message" }, - Properties = new Dictionary + Properties = new() { ["code"] = new OpenApiSchema() { @@ -291,18 +291,18 @@ public async Task ParseStandardPetStoreDocumentShouldSucceed() Url = new Uri("http://opensource.org/licenses/MIT") } }, - Servers = new List - { + Servers = + [ new OpenApiServer { Url = "http://petstore.swagger.io/api" } - }, + ], Paths = new OpenApiPaths { ["/pets"] = new OpenApiPathItem { - Operations = new Dictionary + Operations = new() { [HttpMethod.Get] = new OpenApiOperation { @@ -343,7 +343,7 @@ public async Task ParseStandardPetStoreDocumentShouldSucceed() ["200"] = new OpenApiResponse { Description = "pet response", - Content = new Dictionary + Content = new() { ["application/json"] = new OpenApiMediaType { @@ -366,7 +366,7 @@ public async Task ParseStandardPetStoreDocumentShouldSucceed() ["4XX"] = new OpenApiResponse { Description = "unexpected client error", - Content = new Dictionary + Content = new() { ["text/html"] = new OpenApiMediaType { @@ -377,7 +377,7 @@ public async Task ParseStandardPetStoreDocumentShouldSucceed() ["5XX"] = new OpenApiResponse { Description = "unexpected server error", - Content = new Dictionary + Content = new() { ["text/html"] = new OpenApiMediaType { @@ -395,7 +395,7 @@ public async Task ParseStandardPetStoreDocumentShouldSucceed() { Description = "Pet to add to the store", Required = true, - Content = new Dictionary + Content = new() { ["application/json"] = new OpenApiMediaType { @@ -408,7 +408,7 @@ public async Task ParseStandardPetStoreDocumentShouldSucceed() ["200"] = new OpenApiResponse { Description = "pet response", - Content = new Dictionary + Content = new() { ["application/json"] = new OpenApiMediaType { @@ -419,7 +419,7 @@ public async Task ParseStandardPetStoreDocumentShouldSucceed() ["4XX"] = new OpenApiResponse { Description = "unexpected client error", - Content = new Dictionary + Content = new() { ["text/html"] = new OpenApiMediaType { @@ -430,7 +430,7 @@ public async Task ParseStandardPetStoreDocumentShouldSucceed() ["5XX"] = new OpenApiResponse { Description = "unexpected server error", - Content = new Dictionary + Content = new() { ["text/html"] = new OpenApiMediaType { @@ -444,7 +444,7 @@ public async Task ParseStandardPetStoreDocumentShouldSucceed() }, ["/pets/{id}"] = new OpenApiPathItem { - Operations = new Dictionary + Operations = new() { [HttpMethod.Get] = new OpenApiOperation { @@ -471,7 +471,7 @@ public async Task ParseStandardPetStoreDocumentShouldSucceed() ["200"] = new OpenApiResponse { Description = "pet response", - Content = new Dictionary + Content = new() { ["application/json"] = new OpenApiMediaType { @@ -486,7 +486,7 @@ public async Task ParseStandardPetStoreDocumentShouldSucceed() ["4XX"] = new OpenApiResponse { Description = "unexpected client error", - Content = new Dictionary + Content = new() { ["text/html"] = new OpenApiMediaType { @@ -497,7 +497,7 @@ public async Task ParseStandardPetStoreDocumentShouldSucceed() ["5XX"] = new OpenApiResponse { Description = "unexpected server error", - Content = new Dictionary + Content = new() { ["text/html"] = new OpenApiMediaType { @@ -535,7 +535,7 @@ public async Task ParseStandardPetStoreDocumentShouldSucceed() ["4XX"] = new OpenApiResponse { Description = "unexpected client error", - Content = new Dictionary + Content = new() { ["text/html"] = new OpenApiMediaType { @@ -546,7 +546,7 @@ public async Task ParseStandardPetStoreDocumentShouldSucceed() ["5XX"] = new OpenApiResponse { Description = "unexpected server error", - Content = new Dictionary + Content = new() { ["text/html"] = new OpenApiMediaType { @@ -576,7 +576,7 @@ public async Task ParseModifiedPetStoreDocumentWithTagAndSecurityShouldSucceed() var components = new OpenApiComponents { - Schemas = new Dictionary + Schemas = new() { ["pet1"] = new OpenApiSchema() { @@ -586,7 +586,7 @@ public async Task ParseModifiedPetStoreDocumentWithTagAndSecurityShouldSucceed() "id", "name" }, - Properties = new Dictionary + Properties = new() { ["id"] = new OpenApiSchema() { @@ -610,7 +610,7 @@ public async Task ParseModifiedPetStoreDocumentWithTagAndSecurityShouldSucceed() { "name" }, - Properties = new Dictionary + Properties = new() { ["id"] = new OpenApiSchema() { @@ -635,7 +635,7 @@ public async Task ParseModifiedPetStoreDocumentWithTagAndSecurityShouldSucceed() "code", "message" }, - Properties = new Dictionary + Properties = new() { ["code"] = new OpenApiSchema() { @@ -710,18 +710,18 @@ public async Task ParseModifiedPetStoreDocumentWithTagAndSecurityShouldSucceed() Url = new Uri("http://opensource.org/licenses/MIT") } }, - Servers = new List - { + Servers = + [ new OpenApiServer { Url = "http://petstore.swagger.io/api" } - }, + ], Paths = new OpenApiPaths { ["/pets"] = new OpenApiPathItem { - Operations = new Dictionary + Operations = new() { [HttpMethod.Get] = new OpenApiOperation { @@ -767,7 +767,7 @@ public async Task ParseModifiedPetStoreDocumentWithTagAndSecurityShouldSucceed() ["200"] = new OpenApiResponse { Description = "pet response", - Content = new Dictionary + Content = new() { ["application/json"] = new OpenApiMediaType { @@ -790,7 +790,7 @@ public async Task ParseModifiedPetStoreDocumentWithTagAndSecurityShouldSucceed() ["4XX"] = new OpenApiResponse { Description = "unexpected client error", - Content = new Dictionary + Content = new() { ["text/html"] = new OpenApiMediaType { @@ -801,7 +801,7 @@ public async Task ParseModifiedPetStoreDocumentWithTagAndSecurityShouldSucceed() ["5XX"] = new OpenApiResponse { Description = "unexpected server error", - Content = new Dictionary + Content = new() { ["text/html"] = new OpenApiMediaType { @@ -824,7 +824,7 @@ public async Task ParseModifiedPetStoreDocumentWithTagAndSecurityShouldSucceed() { Description = "Pet to add to the store", Required = true, - Content = new Dictionary + Content = new() { ["application/json"] = new OpenApiMediaType { @@ -837,7 +837,7 @@ public async Task ParseModifiedPetStoreDocumentWithTagAndSecurityShouldSucceed() ["200"] = new OpenApiResponse { Description = "pet response", - Content = new Dictionary + Content = new() { ["application/json"] = new OpenApiMediaType { @@ -848,7 +848,7 @@ public async Task ParseModifiedPetStoreDocumentWithTagAndSecurityShouldSucceed() ["4XX"] = new OpenApiResponse { Description = "unexpected client error", - Content = new Dictionary + Content = new() { ["text/html"] = new OpenApiMediaType { @@ -859,7 +859,7 @@ public async Task ParseModifiedPetStoreDocumentWithTagAndSecurityShouldSucceed() ["5XX"] = new OpenApiResponse { Description = "unexpected server error", - Content = new Dictionary + Content = new() { ["text/html"] = new OpenApiMediaType { @@ -868,24 +868,24 @@ public async Task ParseModifiedPetStoreDocumentWithTagAndSecurityShouldSucceed() } } }, - Security = new List - { + Security = + [ new OpenApiSecurityRequirement { - [new OpenApiSecuritySchemeReference("securitySchemeName1")] = new List(), - [new OpenApiSecuritySchemeReference("securitySchemeName2")] = new List - { + [new OpenApiSecuritySchemeReference("securitySchemeName1")] = [], + [new OpenApiSecuritySchemeReference("securitySchemeName2")] = + [ "scope1", "scope2" - } + ] } - } + ] } } }, ["/pets/{id}"] = new OpenApiPathItem { - Operations = new Dictionary + Operations = new() { [HttpMethod.Get] = new OpenApiOperation { @@ -912,7 +912,7 @@ public async Task ParseModifiedPetStoreDocumentWithTagAndSecurityShouldSucceed() ["200"] = new OpenApiResponse { Description = "pet response", - Content = new Dictionary + Content = new() { ["application/json"] = new OpenApiMediaType { @@ -927,7 +927,7 @@ public async Task ParseModifiedPetStoreDocumentWithTagAndSecurityShouldSucceed() ["4XX"] = new OpenApiResponse { Description = "unexpected client error", - Content = new Dictionary + Content = new() { ["text/html"] = new OpenApiMediaType { @@ -938,7 +938,7 @@ public async Task ParseModifiedPetStoreDocumentWithTagAndSecurityShouldSucceed() ["5XX"] = new OpenApiResponse { Description = "unexpected server error", - Content = new Dictionary + Content = new() { ["text/html"] = new OpenApiMediaType { @@ -976,7 +976,7 @@ public async Task ParseModifiedPetStoreDocumentWithTagAndSecurityShouldSucceed() ["4XX"] = new OpenApiResponse { Description = "unexpected client error", - Content = new Dictionary + Content = new() { ["text/html"] = new OpenApiMediaType { @@ -987,7 +987,7 @@ public async Task ParseModifiedPetStoreDocumentWithTagAndSecurityShouldSucceed() ["5XX"] = new OpenApiResponse { Description = "unexpected server error", - Content = new Dictionary + Content = new() { ["text/html"] = new OpenApiMediaType { @@ -1014,19 +1014,19 @@ public async Task ParseModifiedPetStoreDocumentWithTagAndSecurityShouldSucceed() Description = "tagDescription2" } }, - Security = new List - { + Security = + [ new OpenApiSecurityRequirement { - [new OpenApiSecuritySchemeReference("securitySchemeName1")] = new List(), - [new OpenApiSecuritySchemeReference("securitySchemeName2")] = new List - { + [new OpenApiSecuritySchemeReference("securitySchemeName1")] = [], + [new OpenApiSecuritySchemeReference("securitySchemeName2")] = + [ "scope1", "scope2", "scope3" - } + ] } - } + ] }; expected.RegisterComponents(); expected.SetReferenceHostDocument(); @@ -1101,7 +1101,7 @@ public async Task HeaderParameterShouldAllowExample() AllowReserved = true, Style = ParameterStyle.Simple, Explode = true, - Examples = + Examples = new Dictionary { { "uuid1", new OpenApiExample() { @@ -1247,7 +1247,7 @@ public async Task SerializesDoubleHopeReferences() { Type = JsonSchemaType.Object, Description = "A pet", - Properties = + Properties = new() { ["id"] = new OpenApiSchema { @@ -1272,7 +1272,7 @@ public async Task SerializesDoubleHopeReferences() document.AddComponent("PetReference", petSchemaReference); document.Paths.Add("/pets", new OpenApiPathItem { - Operations = new Dictionary + Operations = new() { [HttpMethod.Get] = new OpenApiOperation { @@ -1282,7 +1282,7 @@ public async Task SerializesDoubleHopeReferences() ["200"] = new OpenApiResponse { Description = "A list of pets", - Content = + Content = new() { ["application/json"] = new OpenApiMediaType { @@ -1338,7 +1338,7 @@ public async Task ParseDocWithRefsUsingProxyReferencesSucceeds() { ["/pets"] = new OpenApiPathItem { - Operations = new Dictionary + Operations = new() { [HttpMethod.Get] = new OpenApiOperation { @@ -1436,17 +1436,17 @@ public void ParseBasicDocumentWithServerVariableShouldSucceed() Version = "0.9.1", }, Servers = + [ + new OpenApiServer { - new OpenApiServer + Url = "http://www.example.org/api/{version}", + Description = "The http endpoint", + Variables = new Dictionary { - Url = "http://www.example.org/api/{version}", - Description = "The http endpoint", - Variables = new Dictionary - { - {"version", new OpenApiServerVariable {Default = "v2", Enum = ["v1", "v2"]}} - } + {"version", new OpenApiServerVariable {Default = "v2", Enum = ["v1", "v2"]}} } - }, + } + ], Paths = new() }; diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiEncodingTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiEncodingTests.cs index 91d2a6059..dee46bc98 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiEncodingTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiEncodingTests.cs @@ -1,9 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. +using System.Collections.Generic; using System.IO; using System.Threading.Tasks; using Microsoft.OpenApi.Models; +using Microsoft.OpenApi.Models.Interfaces; using Microsoft.OpenApi.Reader; using Xunit; @@ -41,7 +43,7 @@ public async Task ParseAdvancedEncodingShouldSucceed() new OpenApiEncoding { ContentType = "image/png, image/jpeg", - Headers = + Headers = new Dictionary { ["X-Rate-Limit-Limit"] = new OpenApiHeader() diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiInfoTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiInfoTests.cs index 8e5cb6389..fd7c5e478 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiInfoTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiInfoTests.cs @@ -2,11 +2,13 @@ // Licensed under the MIT license. using System; +using System.Collections.Generic; using System.IO; using System.Text.Json.Nodes; using System.Threading.Tasks; using FluentAssertions; using Microsoft.OpenApi.Any; +using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Reader; using Xunit; @@ -35,7 +37,7 @@ public async Task ParseAdvancedInfoShouldSucceed() Contact = new OpenApiContact { Email = "example@example.com", - Extensions = + Extensions = new Dictionary { ["x-twitter"] = new OpenApiAny("@exampleTwitterHandler") }, @@ -44,11 +46,14 @@ public async Task ParseAdvancedInfoShouldSucceed() }, License = new OpenApiLicense { - Extensions = { ["x-disclaimer"] = new OpenApiAny("Sample Extension String Disclaimer") }, + Extensions = new Dictionary + { + ["x-disclaimer"] = new OpenApiAny("Sample Extension String Disclaimer") + }, Name = "licenseName", Url = new Uri("http://www.example.com/url2") }, - Extensions = + Extensions = new Dictionary { ["x-something"] = new OpenApiAny("Sample Extension String Something"), ["x-contact"] = new OpenApiAny(new JsonObject() diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiMediaTypeTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiMediaTypeTests.cs index f60ec2820..7bdcf6047 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiMediaTypeTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiMediaTypeTests.cs @@ -1,11 +1,13 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. +using System.Collections.Generic; using System.IO; using System.Threading.Tasks; using FluentAssertions; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; +using Microsoft.OpenApi.Models.Interfaces; using Microsoft.OpenApi.Reader; using Microsoft.OpenApi.Reader.ParseNodes; using Microsoft.OpenApi.Reader.V3; @@ -50,7 +52,7 @@ public async Task ParseMediaTypeWithExamplesShouldSucceed() mediaType.Should().BeEquivalentTo( new OpenApiMediaType { - Examples = + Examples = new Dictionary { ["example1"] = new OpenApiExample() { diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiOperationTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiOperationTests.cs index 1dd9ecce3..e22f02029 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiOperationTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiOperationTests.cs @@ -48,7 +48,7 @@ public async Task ParseOperationWithParameterWithNoLocationShouldSucceed() Description = "", OperationId = "loginUser", Parameters = - { + [ new OpenApiParameter { Name = "username", @@ -70,7 +70,7 @@ public async Task ParseOperationWithParameterWithNoLocationShouldSucceed() Type = JsonSchemaType.String } } - } + ] }; // Assert @@ -98,7 +98,7 @@ public void DeduplicatesTagReferences() Description = "", OperationId = "loginUser", Parameters = - { + [ new OpenApiParameter { Name = "password", @@ -110,7 +110,7 @@ public void DeduplicatesTagReferences() Type = JsonSchemaType.String } } - } + ] }; using var textWriter = new StringWriter(); var writer = new OpenApiJsonWriter(textWriter); diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiParameterTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiParameterTests.cs index fd27c9416..7765545aa 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiParameterTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiParameterTests.cs @@ -110,19 +110,19 @@ public async Task ParseQueryParameterWithObjectTypeAndContentShouldSucceed() { In = ParameterLocation.Query, Name = "coordinates", - Content = + Content = new() { ["application/json"] = new() { Schema = new OpenApiSchema() { Type = JsonSchemaType.Object, - Required = + Required = new HashSet { "lat", "long" }, - Properties = + Properties = new() { ["lat"] = new OpenApiSchema() { @@ -273,7 +273,7 @@ public async Task ParseParameterWithExamplesShouldSucceed() Name = "username", Description = "username to fetch", Required = true, - Examples = + Examples = new Dictionary { ["example1"] = new OpenApiExample() { @@ -320,18 +320,18 @@ public void ParseParameterWithReferenceWorks() Version = "1.0.0", Title = "Swagger Petstore (Simple)" }, - Servers = new List - { + Servers = + [ new OpenApiServer { Url = "http://petstore.swagger.io/api" } - }, + ], Paths = new OpenApiPaths { ["/pets"] = new OpenApiPathItem { - Operations = new Dictionary + Operations = new() { [HttpMethod.Get] = new OpenApiOperation { diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs index 0ea179f56..d9b4b1901 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs @@ -18,6 +18,7 @@ using System.Threading.Tasks; using System.Net.Http; using Microsoft.OpenApi.YamlReader; +using Microsoft.OpenApi.Models.Interfaces; namespace Microsoft.OpenApi.Readers.Tests.V3Tests { @@ -121,7 +122,7 @@ public void ParsePathFragmentShouldSucceed() new OpenApiPathItem { Summary = "externally referenced path item", - Operations = new Dictionary + Operations = new() { [HttpMethod.Get] = new OpenApiOperation() { @@ -194,7 +195,7 @@ public void ParseBasicSchemaWithExampleShouldSucceed() new OpenApiSchema { Type = JsonSchemaType.Object, - Properties = + Properties = new() { ["id"] = new OpenApiSchema() { @@ -206,7 +207,7 @@ public void ParseBasicSchemaWithExampleShouldSucceed() Type = JsonSchemaType.String } }, - Required = + Required = new HashSet { "name" }, @@ -240,12 +241,12 @@ public async Task ParseBasicSchemaWithReferenceShouldSucceed() var expectedComponents = new OpenApiComponents { - Schemas = + Schemas = new() { ["ErrorModel"] = new OpenApiSchema() { Type = JsonSchemaType.Object, - Properties = + Properties = new() { ["code"] = new OpenApiSchema() { @@ -258,7 +259,7 @@ public async Task ParseBasicSchemaWithReferenceShouldSucceed() Type = JsonSchemaType.String } }, - Required = + Required = new HashSet { "message", "code" @@ -267,13 +268,13 @@ public async Task ParseBasicSchemaWithReferenceShouldSucceed() ["ExtendedErrorModel"] = new OpenApiSchema() { AllOf = - { + [ new OpenApiSchemaReference("ErrorModel", result.Document), new OpenApiSchema { Type = JsonSchemaType.Object, - Required = {"rootCause"}, - Properties = + Required = new HashSet {"rootCause"}, + Properties = new() { ["rootCause"] = new OpenApiSchema() { @@ -281,7 +282,7 @@ public async Task ParseBasicSchemaWithReferenceShouldSucceed() } } } - } + ] } } }; @@ -297,7 +298,7 @@ public async Task ParseAdvancedSchemaWithReferenceShouldSucceed() var expectedComponents = new OpenApiComponents { - Schemas = + Schemas = new() { ["Pet"] = new OpenApiSchema() { @@ -306,7 +307,7 @@ public async Task ParseAdvancedSchemaWithReferenceShouldSucceed() { PropertyName = "petType" }, - Properties = + Properties = new() { ["name"] = new OpenApiSchema() { @@ -317,7 +318,7 @@ public async Task ParseAdvancedSchemaWithReferenceShouldSucceed() Type = JsonSchemaType.String } }, - Required = + Required = new HashSet { "name", "petType" @@ -327,41 +328,41 @@ public async Task ParseAdvancedSchemaWithReferenceShouldSucceed() { Description = "A representation of a cat", AllOf = - { + [ new OpenApiSchemaReference("Pet", result.Document), new OpenApiSchema { Type = JsonSchemaType.Object, - Required = {"huntingSkill"}, - Properties = + Required = new HashSet{"huntingSkill"}, + Properties = new() { ["huntingSkill"] = new OpenApiSchema() { Type = JsonSchemaType.String, Description = "The measured skill for hunting", Enum = - { + [ "clueless", "lazy", "adventurous", "aggressive" - } + ] } } } - } + ] }, ["Dog"] = new OpenApiSchema() { Description = "A representation of a dog", AllOf = - { + [ new OpenApiSchemaReference("Pet", result.Document), new OpenApiSchema { Type = JsonSchemaType.Object, - Required = {"packSize"}, - Properties = + Required = new HashSet{"packSize"}, + Properties = new() { ["packSize"] = new OpenApiSchema() { @@ -373,7 +374,7 @@ public async Task ParseAdvancedSchemaWithReferenceShouldSucceed() } } } - } + ] } } }; @@ -403,42 +404,42 @@ public async Task ParseExternalReferenceSchemaShouldSucceed() var expectedComponents = new OpenApiComponents { - Schemas = + Schemas = new() { ["RelativePathModel"] = new OpenApiSchema() { AllOf = - { + [ new OpenApiSchemaReference("ExternalRelativePathModel", result.Document, "./FirstLevel/SecondLevel/ThridLevel/File.json") - } + ] }, ["SimpleRelativePathModel"] = new OpenApiSchema() { AllOf = - { + [ new OpenApiSchemaReference("ExternalSimpleRelativePathModel", result.Document, "File.json") - } + ] }, ["AbsoluteWindowsPathModel"] = new OpenApiSchema() { AllOf = - { + [ new OpenApiSchemaReference("ExternalAbsWindowsPathModel", result.Document, @"A:\Dir\File.json") - } + ] }, ["AbsoluteUnixPathModel"] = new OpenApiSchema() { AllOf = - { + [ new OpenApiSchemaReference("ExternalAbsUnixPathModel", result.Document, "/Dir/File.json") - } + ] }, ["HttpsUrlModel"] = new OpenApiSchema() { AllOf = - { + [ new OpenApiSchemaReference("ExternalHttpsModel", result.Document, "https://host.lan:1234/path/to/file/resource.json") - } + ] } } }; diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSecuritySchemeTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSecuritySchemeTests.cs index ed864d240..cdab5c3ef 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSecuritySchemeTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSecuritySchemeTests.cs @@ -77,7 +77,7 @@ public async Task ParseOAuth2SecuritySchemeShouldSucceed() Implicit = new OpenApiOAuthFlow { AuthorizationUrl = new Uri("https://example.com/api/oauth/dialog"), - Scopes = + Scopes = new System.Collections.Generic.Dictionary { ["write:pets"] = "modify pets in your account", ["read:pets"] = "read your pets" diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.cs index 2bc407557..a6f724c66 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.cs @@ -1,12 +1,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. +using System.Collections.Generic; using System.Globalization; using System.IO; using System.Net.Http; using System.Threading.Tasks; using Microsoft.OpenApi.Expressions; using Microsoft.OpenApi.Models; +using Microsoft.OpenApi.Models.Interfaces; using Microsoft.OpenApi.Models.References; using Microsoft.OpenApi.Writers; using VerifyXunit; @@ -19,19 +21,19 @@ public class OpenApiCallbackTests { private static OpenApiCallback AdvancedCallback => new() { - PathItems = + PathItems = new Dictionary { [RuntimeExpression.Build("$request.body#/url")] = new OpenApiPathItem() { - Operations = + Operations = new() { [HttpMethod.Post] = new() { RequestBody = new OpenApiRequestBody() { - Content = + Content = new() { ["application/json"] = new() { @@ -59,19 +61,19 @@ public class OpenApiCallbackTests private static OpenApiCallback ReferencedCallback => new() { - PathItems = + PathItems = new Dictionary { [RuntimeExpression.Build("$request.body#/url")] = new OpenApiPathItem() { - Operations = + Operations = new() { [HttpMethod.Post] = new() { RequestBody = new OpenApiRequestBody() { - Content = + Content = new() { ["application/json"] = new() { diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiComponentsTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiComponentsTests.cs index b0607f57e..65c53b322 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiComponentsTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiComponentsTests.cs @@ -17,11 +17,11 @@ public class OpenApiComponentsTests { public static OpenApiComponents AdvancedComponents = new() { - Schemas = new Dictionary + Schemas = new() { ["schema1"] = new OpenApiSchema() { - Properties = new Dictionary + Properties = new() { ["property2"] = new OpenApiSchema() { @@ -66,11 +66,11 @@ public class OpenApiComponentsTests public static OpenApiComponents AdvancedComponentsWithReference = new() { - Schemas = new Dictionary + Schemas = new() { ["schema1"] = new OpenApiSchema() { - Properties = new Dictionary + Properties = new() { ["property2"] = new OpenApiSchema() { @@ -81,7 +81,7 @@ public class OpenApiComponentsTests }, ["schema2"] = new OpenApiSchema() { - Properties = new Dictionary + Properties = new() { ["property2"] = new OpenApiSchema() { @@ -123,7 +123,7 @@ public class OpenApiComponentsTests public static OpenApiComponents BrokenComponents = new() { - Schemas = new Dictionary + Schemas = new() { ["schema1"] = new OpenApiSchema() { @@ -134,8 +134,8 @@ public class OpenApiComponentsTests ["schema4"] = new OpenApiSchema() { Type = JsonSchemaType.String, - AllOf = new List - { + AllOf = + [ null, null, new OpenApiSchema() @@ -144,20 +144,20 @@ public class OpenApiComponentsTests }, null, null - } + ] } } }; public static OpenApiComponents TopLevelReferencingComponents = new() { - Schemas = + Schemas = new() { ["schema1"] = new OpenApiSchemaReference("schema2", null), ["schema2"] = new OpenApiSchema() { Type = JsonSchemaType.Object, - Properties = + Properties = new() { ["property1"] = new OpenApiSchema() { @@ -170,12 +170,12 @@ public class OpenApiComponentsTests public static OpenApiComponents TopLevelSelfReferencingComponentsWithOtherProperties = new() { - Schemas = + Schemas = new() { ["schema1"] = new OpenApiSchema() { Type = JsonSchemaType.Object, - Properties = + Properties = new() { ["property1"] = new OpenApiSchema() { @@ -186,7 +186,7 @@ public class OpenApiComponentsTests ["schema2"] = new OpenApiSchema() { Type = JsonSchemaType.Object, - Properties = + Properties = new() { ["property1"] = new OpenApiSchema() { @@ -199,7 +199,7 @@ public class OpenApiComponentsTests public static OpenApiComponents TopLevelSelfReferencingComponents = new() { - Schemas = + Schemas = new() { ["schema1"] = new OpenApiSchemaReference("schema1", null) } @@ -207,11 +207,11 @@ public class OpenApiComponentsTests public static OpenApiComponents ComponentsWithPathItem = new OpenApiComponents { - Schemas = new Dictionary() + Schemas = new() { ["schema1"] = new OpenApiSchema() { - Properties = new Dictionary() + Properties = new() { ["property2"] = new OpenApiSchema() { @@ -223,7 +223,7 @@ public class OpenApiComponentsTests ["schema2"] = new OpenApiSchema() { - Properties = new Dictionary() + Properties = new() { ["property2"] = new OpenApiSchema() { @@ -236,14 +236,14 @@ public class OpenApiComponentsTests { ["/pets"] = new OpenApiPathItem { - Operations = new Dictionary + Operations = new() { [HttpMethod.Post] = new OpenApiOperation { RequestBody = new OpenApiRequestBody { Description = "Information about a new pet in the system", - Content = new Dictionary + Content = new() { ["application/json"] = new OpenApiMediaType { diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiContactTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiContactTests.cs index aec4815e0..65f34c65b 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiContactTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiContactTests.cs @@ -21,7 +21,7 @@ public class OpenApiContactTests Name = "API Support", Url = new("http://www.example.com/support"), Email = "support@example.com", - Extensions = new Dictionary + Extensions = new() { {"x-internal-id", new OpenApiAny(42)} } diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs index 6c3498007..7b391c401 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs @@ -13,9 +13,7 @@ using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.Interfaces; using Microsoft.OpenApi.Models.References; -using Microsoft.OpenApi.Reader; using Microsoft.OpenApi.Writers; -using Microsoft.OpenApi.YamlReader; using Microsoft.VisualBasic; using VerifyXunit; using Xunit; @@ -27,13 +25,13 @@ public class OpenApiDocumentTests { public static readonly OpenApiComponents TopLevelReferencingComponents = new OpenApiComponents() { - Schemas = + Schemas = new() { ["schema1"] = new OpenApiSchemaReference("schema2", null), ["schema2"] = new OpenApiSchema() { Type = JsonSchemaType.Object, - Properties = + Properties = new() { ["property1"] = new OpenApiSchema() { @@ -47,12 +45,12 @@ public class OpenApiDocumentTests public static readonly OpenApiComponents TopLevelSelfReferencingComponentsWithOtherProperties = new OpenApiComponents() { - Schemas = + Schemas = new() { ["schema1"] = new OpenApiSchema() { Type = JsonSchemaType.Object, - Properties = + Properties = new() { ["property1"] = new OpenApiSchema() { @@ -65,7 +63,7 @@ public class OpenApiDocumentTests ["schema2"] = new OpenApiSchema() { Type = JsonSchemaType.Object, - Properties = + Properties = new() { ["property1"] = new OpenApiSchema() { @@ -79,7 +77,7 @@ public class OpenApiDocumentTests public static readonly OpenApiComponents TopLevelSelfReferencingComponents = new OpenApiComponents() { - Schemas = + Schemas = new() { ["schema1"] = new OpenApiSchema() { @@ -119,7 +117,7 @@ public class OpenApiDocumentTests public static readonly OpenApiComponents AdvancedComponentsWithReference = new OpenApiComponents { - Schemas = new Dictionary + Schemas = new() { ["pet"] = new OpenApiSchema() { @@ -129,7 +127,7 @@ public class OpenApiDocumentTests "id", "name" }, - Properties = new Dictionary + Properties = new() { ["id"] = new OpenApiSchema() { @@ -153,7 +151,7 @@ public class OpenApiDocumentTests { "name" }, - Properties = new Dictionary + Properties = new() { ["id"] = new OpenApiSchema() { @@ -178,7 +176,7 @@ public class OpenApiDocumentTests "code", "message" }, - Properties = new Dictionary + Properties = new() { ["code"] = new OpenApiSchema() { @@ -222,18 +220,18 @@ public class OpenApiDocumentTests Url = new Uri("http://opensource.org/licenses/MIT") } }, - Servers = new List - { + Servers = + [ new OpenApiServer { Url = "http://petstore.swagger.io/api" } - }, + ], Paths = new OpenApiPaths { ["/pets"] = new OpenApiPathItem { - Operations = new Dictionary + Operations = new() { [HttpMethod.Get] = new OpenApiOperation { @@ -274,7 +272,7 @@ public class OpenApiDocumentTests ["200"] = new OpenApiResponse { Description = "pet response", - Content = new Dictionary + Content = new() { ["application/json"] = new OpenApiMediaType { @@ -297,7 +295,7 @@ public class OpenApiDocumentTests ["4XX"] = new OpenApiResponse { Description = "unexpected client error", - Content = new Dictionary + Content = new() { ["text/html"] = new OpenApiMediaType { @@ -308,7 +306,7 @@ public class OpenApiDocumentTests ["5XX"] = new OpenApiResponse { Description = "unexpected server error", - Content = new Dictionary + Content = new() { ["text/html"] = new OpenApiMediaType { @@ -326,7 +324,7 @@ public class OpenApiDocumentTests { Description = "Pet to add to the store", Required = true, - Content = new Dictionary + Content = new() { ["application/json"] = new OpenApiMediaType { @@ -339,7 +337,7 @@ public class OpenApiDocumentTests ["200"] = new OpenApiResponse { Description = "pet response", - Content = new Dictionary + Content = new() { ["application/json"] = new OpenApiMediaType { @@ -350,7 +348,7 @@ public class OpenApiDocumentTests ["4XX"] = new OpenApiResponse { Description = "unexpected client error", - Content = new Dictionary + Content = new() { ["text/html"] = new OpenApiMediaType { @@ -361,7 +359,7 @@ public class OpenApiDocumentTests ["5XX"] = new OpenApiResponse { Description = "unexpected server error", - Content = new Dictionary + Content = new() { ["text/html"] = new OpenApiMediaType { @@ -375,7 +373,7 @@ public class OpenApiDocumentTests }, ["/pets/{id}"] = new OpenApiPathItem { - Operations = new Dictionary + Operations = new() { [HttpMethod.Get] = new OpenApiOperation { @@ -402,7 +400,7 @@ public class OpenApiDocumentTests ["200"] = new OpenApiResponse { Description = "pet response", - Content = new Dictionary + Content = new() { ["application/json"] = new OpenApiMediaType { @@ -417,7 +415,7 @@ public class OpenApiDocumentTests ["4XX"] = new OpenApiResponse { Description = "unexpected client error", - Content = new Dictionary + Content = new() { ["text/html"] = new OpenApiMediaType { @@ -428,7 +426,7 @@ public class OpenApiDocumentTests ["5XX"] = new OpenApiResponse { Description = "unexpected server error", - Content = new Dictionary + Content = new() { ["text/html"] = new OpenApiMediaType { @@ -466,7 +464,7 @@ public class OpenApiDocumentTests ["4XX"] = new OpenApiResponse { Description = "unexpected client error", - Content = new Dictionary + Content = new() { ["text/html"] = new OpenApiMediaType { @@ -477,7 +475,7 @@ public class OpenApiDocumentTests ["5XX"] = new OpenApiResponse { Description = "unexpected server error", - Content = new Dictionary + Content = new() { ["text/html"] = new OpenApiMediaType { @@ -496,7 +494,7 @@ public class OpenApiDocumentTests public static readonly OpenApiComponents AdvancedComponents = new OpenApiComponents { - Schemas = new Dictionary + Schemas = new() { ["pet"] = new OpenApiSchema() { @@ -506,7 +504,7 @@ public class OpenApiDocumentTests "id", "name" }, - Properties = new Dictionary + Properties = new() { ["id"] = new OpenApiSchema() { @@ -530,7 +528,7 @@ public class OpenApiDocumentTests { "name" }, - Properties = new Dictionary + Properties = new() { ["id"] = new OpenApiSchema() { @@ -555,7 +553,7 @@ public class OpenApiDocumentTests "code", "message" }, - Properties = new Dictionary + Properties = new() { ["code"] = new OpenApiSchema() { @@ -598,25 +596,25 @@ public class OpenApiDocumentTests Url = new Uri("http://opensource.org/licenses/MIT") } }, - Servers = new List - { + Servers = + [ new OpenApiServer { Url = "http://petstore.swagger.io/api" } - }, + ], Paths = new OpenApiPaths { ["/pets"] = new OpenApiPathItem { - Operations = new Dictionary + Operations = new() { [HttpMethod.Get] = new OpenApiOperation { Description = "Returns all pets from the system that the user has access to", OperationId = "findPets", - Parameters = new List - { + Parameters = + [ new OpenApiParameter { Name = "tags", @@ -644,13 +642,13 @@ public class OpenApiDocumentTests Format = "int32" } } - }, + ], Responses = new OpenApiResponses { ["200"] = new OpenApiResponse { Description = "pet response", - Content = new Dictionary + Content = new() { ["application/json"] = new OpenApiMediaType { @@ -673,7 +671,7 @@ public class OpenApiDocumentTests ["4XX"] = new OpenApiResponse { Description = "unexpected client error", - Content = new Dictionary + Content = new() { ["text/html"] = new OpenApiMediaType { @@ -684,7 +682,7 @@ public class OpenApiDocumentTests ["5XX"] = new OpenApiResponse { Description = "unexpected server error", - Content = new Dictionary + Content = new() { ["text/html"] = new OpenApiMediaType { @@ -702,7 +700,7 @@ public class OpenApiDocumentTests { Description = "Pet to add to the store", Required = true, - Content = new Dictionary + Content = new() { ["application/json"] = new OpenApiMediaType { @@ -715,7 +713,7 @@ public class OpenApiDocumentTests ["200"] = new OpenApiResponse { Description = "pet response", - Content = new Dictionary + Content = new() { ["application/json"] = new OpenApiMediaType { @@ -726,7 +724,7 @@ public class OpenApiDocumentTests ["4XX"] = new OpenApiResponse { Description = "unexpected client error", - Content = new Dictionary + Content = new() { ["text/html"] = new OpenApiMediaType { @@ -737,7 +735,7 @@ public class OpenApiDocumentTests ["5XX"] = new OpenApiResponse { Description = "unexpected server error", - Content = new Dictionary + Content = new() { ["text/html"] = new OpenApiMediaType { @@ -751,15 +749,15 @@ public class OpenApiDocumentTests }, ["/pets/{id}"] = new OpenApiPathItem { - Operations = new Dictionary + Operations = new() { [HttpMethod.Get] = new OpenApiOperation { Description = "Returns a user based on a single ID, if the user does not have access to the pet", OperationId = "findPetById", - Parameters = new List - { + Parameters = + [ new OpenApiParameter { Name = "id", @@ -772,13 +770,13 @@ public class OpenApiDocumentTests Format = "int64" } } - }, + ], Responses = new OpenApiResponses { ["200"] = new OpenApiResponse { Description = "pet response", - Content = new Dictionary + Content = new() { ["application/json"] = new OpenApiMediaType { @@ -793,7 +791,7 @@ public class OpenApiDocumentTests ["4XX"] = new OpenApiResponse { Description = "unexpected client error", - Content = new Dictionary + Content = new() { ["text/html"] = new OpenApiMediaType { @@ -804,7 +802,7 @@ public class OpenApiDocumentTests ["5XX"] = new OpenApiResponse { Description = "unexpected server error", - Content = new Dictionary + Content = new() { ["text/html"] = new OpenApiMediaType { @@ -818,8 +816,8 @@ public class OpenApiDocumentTests { Description = "deletes a single pet based on the ID supplied", OperationId = "deletePet", - Parameters = new List - { + Parameters = + [ new OpenApiParameter { Name = "id", @@ -832,7 +830,7 @@ public class OpenApiDocumentTests Format = "int64" } } - }, + ], Responses = new OpenApiResponses { ["204"] = new OpenApiResponse @@ -842,7 +840,7 @@ public class OpenApiDocumentTests ["4XX"] = new OpenApiResponse { Description = "unexpected client error", - Content = new Dictionary + Content = new() { ["text/html"] = new OpenApiMediaType { @@ -853,7 +851,7 @@ public class OpenApiDocumentTests ["5XX"] = new OpenApiResponse { Description = "unexpected server error", - Content = new Dictionary + Content = new() { ["text/html"] = new OpenApiMediaType { @@ -881,14 +879,14 @@ public class OpenApiDocumentTests { ["newPet"] = new OpenApiPathItem { - Operations = new Dictionary + Operations = new() { [HttpMethod.Post] = new OpenApiOperation { RequestBody = new OpenApiRequestBody { Description = "Information about a new pet in the system", - Content = new Dictionary + Content = new() { ["application/json"] = new OpenApiMediaType { @@ -909,7 +907,7 @@ public class OpenApiDocumentTests }, Components = new OpenApiComponents { - Schemas = new Dictionary + Schemas = new() { ["Pet"] = new OpenApiSchema() { @@ -917,7 +915,7 @@ public class OpenApiDocumentTests { "id", "name" }, - Properties = new Dictionary + Properties = new() { ["id"] = new OpenApiSchema() { @@ -946,24 +944,24 @@ public class OpenApiDocumentTests Title = "Swagger Petstore (Simple)", Description = "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification", }, - Servers = new List - { + Servers = + [ new OpenApiServer { Url = "http://petstore.swagger.io/api" } - }, + ], Paths = new OpenApiPaths { ["/add/{operand1}/{operand2}"] = new OpenApiPathItem { - Operations = new Dictionary + Operations = new() { [HttpMethod.Get] = new OpenApiOperation { OperationId = "addByOperand1AndByOperand2", - Parameters = new List - { + Parameters = + [ new OpenApiParameter { Name = "operand1", @@ -973,12 +971,12 @@ public class OpenApiDocumentTests Schema = new OpenApiSchema() { Type = JsonSchemaType.Integer, - Extensions = new Dictionary + Extensions = new() { ["my-extension"] = new OpenApiAny(4) } }, - Extensions = new Dictionary + Extensions = new() { ["my-extension"] = new OpenApiAny(4), } @@ -992,23 +990,23 @@ public class OpenApiDocumentTests Schema = new OpenApiSchema() { Type = JsonSchemaType.Integer, - Extensions = new Dictionary + Extensions = new() { ["my-extension"] = new OpenApiAny(4) } }, - Extensions = new Dictionary + Extensions = new() { ["my-extension"] = new OpenApiAny(4), } }, - }, + ], Responses = new OpenApiResponses { ["200"] = new OpenApiResponse { Description = "pet response", - Content = new Dictionary + Content = new() { ["application/json"] = new OpenApiMediaType { @@ -1050,8 +1048,8 @@ public class OpenApiDocumentTests Url = new("http://opensource.org/licenses/MIT") } }, - Servers = new List - { + Servers = + [ new() { Url = "https://{endpoint}/openai", @@ -1063,19 +1061,19 @@ public class OpenApiDocumentTests } } } - }, + ], Paths = new() { ["/pets"] = new OpenApiPathItem() { - Operations = new Dictionary + Operations = new() { [HttpMethod.Get] = new() { Description = "Returns all pets from the system that the user has access to", OperationId = "findPets", - Parameters = new List - { + Parameters = + [ new OpenApiParameter() { Name = "tags", @@ -1103,13 +1101,13 @@ public class OpenApiDocumentTests Format = "int32" } } - }, + ], Responses = new() { ["200"] = new OpenApiResponse() { Description = "pet response", - Content = new Dictionary + Content = new() { ["application/json"] = new() { @@ -1132,7 +1130,7 @@ public class OpenApiDocumentTests ["4XX"] = new OpenApiResponse() { Description = "unexpected client error", - Content = new Dictionary + Content = new() { ["text/html"] = new() { @@ -1143,7 +1141,7 @@ public class OpenApiDocumentTests ["5XX"] = new OpenApiResponse() { Description = "unexpected server error", - Content = new Dictionary + Content = new() { ["text/html"] = new() { @@ -1161,7 +1159,7 @@ public class OpenApiDocumentTests { Description = "Pet to add to the store", Required = true, - Content = new Dictionary + Content = new() { ["application/json"] = new() { @@ -1174,7 +1172,7 @@ public class OpenApiDocumentTests ["200"] = new OpenApiResponse() { Description = "pet response", - Content = new Dictionary + Content = new() { ["application/json"] = new() { @@ -1185,7 +1183,7 @@ public class OpenApiDocumentTests ["4XX"] = new OpenApiResponse() { Description = "unexpected client error", - Content = new Dictionary + Content = new() { ["text/html"] = new() { @@ -1196,7 +1194,7 @@ public class OpenApiDocumentTests ["5XX"] = new OpenApiResponse() { Description = "unexpected server error", - Content = new Dictionary + Content = new() { ["text/html"] = new() { @@ -1210,15 +1208,15 @@ public class OpenApiDocumentTests }, ["/pets/{id}"] = new OpenApiPathItem() { - Operations = new Dictionary + Operations = new() { [HttpMethod.Get] = new() { Description = "Returns a user based on a single ID, if the user does not have access to the pet", OperationId = "findPetById", - Parameters = new List - { + Parameters = + [ new OpenApiParameter() { Name = "id", @@ -1231,13 +1229,13 @@ public class OpenApiDocumentTests Format = "int64" } } - }, + ], Responses = new() { ["200"] = new OpenApiResponse() { Description = "pet response", - Content = new Dictionary + Content = new() { ["application/json"] = new() { @@ -1252,7 +1250,7 @@ public class OpenApiDocumentTests ["4XX"] = new OpenApiResponse() { Description = "unexpected client error", - Content = new Dictionary + Content = new() { ["text/html"] = new() { @@ -1263,7 +1261,7 @@ public class OpenApiDocumentTests ["5XX"] = new OpenApiResponse() { Description = "unexpected server error", - Content = new Dictionary + Content = new() { ["text/html"] = new() { @@ -1277,8 +1275,8 @@ public class OpenApiDocumentTests { Description = "deletes a single pet based on the ID supplied", OperationId = "deletePet", - Parameters = new List - { + Parameters = + [ new OpenApiParameter() { Name = "id", @@ -1291,7 +1289,7 @@ public class OpenApiDocumentTests Format = "int64" } } - }, + ], Responses = new() { ["204"] = new OpenApiResponse() @@ -1301,7 +1299,7 @@ public class OpenApiDocumentTests ["4XX"] = new OpenApiResponse() { Description = "unexpected client error", - Content = new Dictionary + Content = new() { ["text/html"] = new() { @@ -1312,7 +1310,7 @@ public class OpenApiDocumentTests ["5XX"] = new OpenApiResponse() { Description = "unexpected server error", - Content = new Dictionary + Content = new() { ["text/html"] = new() { @@ -1535,7 +1533,7 @@ public async Task SerializeDocumentWithReferenceButNoComponents() { ["/"] = new OpenApiPathItem { - Operations = new Dictionary + Operations = new() { [HttpMethod.Get] = new OpenApiOperation { @@ -1543,7 +1541,7 @@ public async Task SerializeDocumentWithReferenceButNoComponents() { ["200"] = new OpenApiResponse { - Content = new Dictionary() + Content = new() { ["application/json"] = new OpenApiMediaType { @@ -1578,12 +1576,12 @@ public async Task SerializeRelativePathAsV2JsonWorks() var doc = new OpenApiDocument() { Info = new OpenApiInfo() { Version = "1.0.0" }, - Servers = new List() { + Servers = [ new OpenApiServer() { Url = "/server1" } - } + ] }; // Act @@ -1608,12 +1606,12 @@ public async Task SerializeRelativePathWithHostAsV2JsonWorks() var doc = new OpenApiDocument() { Info = new OpenApiInfo() { Version = "1.0.0" }, - Servers = new List() { + Servers = [ new OpenApiServer() { Url = "//example.org/server1" } - } + ] }; // Act @@ -1637,12 +1635,12 @@ public async Task SerializeRelativeRootPathWithHostAsV2JsonWorks() var doc = new OpenApiDocument() { Info = new OpenApiInfo() { Version = "1.0.0" }, - Servers = new List() { + Servers = [ new OpenApiServer() { Url = "//example.org/" } - } + ] }; // Act @@ -1708,7 +1706,7 @@ public async Task SerializeV2DocumentWithNonArraySchemaTypeDoesNotWriteOutCollec { ["/foo"] = new OpenApiPathItem { - Operations = new Dictionary + Operations = new() { [HttpMethod.Get] = new OpenApiOperation { @@ -1775,7 +1773,7 @@ public async Task SerializeV2DocumentWithStyleAsNullDoesNotWriteOutStyleValue() { ["/foo"] = new OpenApiPathItem { - Operations = new Dictionary + Operations = new() { [HttpMethod.Get] = new OpenApiOperation { @@ -1800,7 +1798,7 @@ public async Task SerializeV2DocumentWithStyleAsNullDoesNotWriteOutStyleValue() ["200"] = new OpenApiResponse { Description = "foo", - Content = new Dictionary + Content = new() { ["text/plain"] = new OpenApiMediaType { @@ -1831,7 +1829,7 @@ public void OpenApiDocumentCopyConstructorWithAnnotationsSucceeds() { var baseDocument = new OpenApiDocument { - Metadata = new Dictionary + Metadata = new() { ["key1"] = "value1", ["key2"] = 2 @@ -1856,13 +1854,13 @@ public void SerializeExamplesDoesNotThrowNullReferenceException() { ["test"] = new OpenApiPathItem() { - Operations = new Dictionary() + Operations = new() { [HttpMethod.Post] = new OpenApiOperation { RequestBody = new OpenApiRequestBody() { - Content = + Content = new() { ["application/json"] = new OpenApiMediaType() { @@ -2079,7 +2077,7 @@ public async Task SerializeDocumentTagsWithMultipleExtensionsWorks() new OpenApiTag { Name = "tag1", - Extensions = new Dictionary + Extensions = new() { ["x-tag1"] = new OpenApiAny("tag1") } @@ -2087,7 +2085,7 @@ public async Task SerializeDocumentTagsWithMultipleExtensionsWorks() new OpenApiTag { Name = "tag2", - Extensions = new Dictionary + Extensions = new() { ["x-tag2"] = new OpenApiAny("tag2") } @@ -2108,7 +2106,7 @@ public void DeduplicatesTags() new OpenApiTag { Name = "tag1", - Extensions = new Dictionary + Extensions = new() { ["x-tag1"] = new OpenApiAny("tag1") } @@ -2116,7 +2114,7 @@ public void DeduplicatesTags() new OpenApiTag { Name = "tag2", - Extensions = new Dictionary + Extensions = new() { ["x-tag2"] = new OpenApiAny("tag2") } @@ -2124,7 +2122,7 @@ public void DeduplicatesTags() new OpenApiTag { Name = "tag1", - Extensions = new Dictionary + Extensions = new() { ["x-tag1"] = new OpenApiAny("tag1") } diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiInfoTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiInfoTests.cs index 65ded8841..08300a4ff 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiInfoTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiInfoTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System.Collections.Generic; @@ -22,7 +22,7 @@ public class OpenApiInfoTests Contact = OpenApiContactTests.AdvanceContact, License = OpenApiLicenseTests.AdvanceLicense, Version = "1.1.1", - Extensions = new Dictionary + Extensions = new() { {"x-updated", new OpenApiAny("metadata")} } diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiLicenseTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiLicenseTests.cs index 7daa55e29..acad2216a 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiLicenseTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiLicenseTests.cs @@ -23,7 +23,7 @@ public class OpenApiLicenseTests { Name = "Apache 2.0", Url = new("http://www.apache.org/licenses/LICENSE-2.0.html"), - Extensions = new Dictionary + Extensions = new() { {"x-copyright", new OpenApiAny("Abc")} } diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.cs index a6b4bc500..03b406adf 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.cs @@ -1,12 +1,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. +using System.Collections.Generic; using System.Globalization; using System.IO; using System.Text.Json.Nodes; using System.Threading.Tasks; using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Expressions; +using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.References; using Microsoft.OpenApi.Writers; @@ -21,7 +23,7 @@ public class OpenApiLinkTests private static OpenApiLink AdvancedLink => new() { OperationId = "operationId1", - Parameters = + Parameters = new Dictionary { ["parameter1"] = new() { @@ -46,7 +48,7 @@ public class OpenApiLinkTests private static OpenApiLink ReferencedLink => new() { OperationId = "operationId1", - Parameters = + Parameters = new Dictionary { ["parameter1"] = new() { @@ -124,8 +126,10 @@ public void LinkExtensionsSerializationWorks() // Arrange var link = new OpenApiLink() { - Extensions = { - { "x-display", new OpenApiAny("Abc") } + Extensions = new() + { + { "x-display", new OpenApiAny("Abc") + } } }; diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiMediaTypeTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiMediaTypeTests.cs index ef1ebb420..3f3c93889 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiMediaTypeTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiMediaTypeTests.cs @@ -79,7 +79,8 @@ public class OpenApiMediaTypeTests public static OpenApiMediaType MediaTypeWithObjectExamples = new() { - Examples = { + Examples = new Dictionary + { ["object1"] = new OpenApiExample() { Value = new JsonObject @@ -436,7 +437,7 @@ public void MediaTypeCopyConstructorWorks() Example = 42, Examples = new Dictionary(), Encoding = new Dictionary(), - Extensions = new Dictionary() + Extensions = new() }; // Assert diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs index d7315d5ab..a862abdd6 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs @@ -44,7 +44,7 @@ public class OpenApiOperationTests { Description = "description2", Required = true, - Content = new Dictionary + Content = new() { ["application/json"] = new() { @@ -62,7 +62,7 @@ public class OpenApiOperationTests ["200"] = new OpenApiResponseReference("response1"), ["400"] = new OpenApiResponse() { - Content = new Dictionary + Content = new() { ["application/json"] = new() { @@ -76,14 +76,14 @@ public class OpenApiOperationTests } } }, - Servers = new List - { + Servers = + [ new() { Url = "http://server.com", Description = "serverDescription" } - }, + ], Metadata = new Dictionary { { "key1", "value1" }, { "key2", 2 } }, }; @@ -118,7 +118,7 @@ public class OpenApiOperationTests { Description = "description2", Required = true, - Content = new Dictionary + Content = new() { ["application/json"] = new() { @@ -136,7 +136,7 @@ public class OpenApiOperationTests ["200"] = new OpenApiResponseReference("response1"), ["400"] = new OpenApiResponse() { - Content = new Dictionary + Content = new() { ["application/json"] = new() { @@ -150,26 +150,26 @@ public class OpenApiOperationTests } } }, - Security = new List - { + Security = + [ new() { - [new OpenApiSecuritySchemeReference("securitySchemeId1", __advancedOperationWithTagsAndSecurity_supportingDocument)] = new List(), - [new OpenApiSecuritySchemeReference("securitySchemeId2", __advancedOperationWithTagsAndSecurity_supportingDocument)] = new List - { + [new OpenApiSecuritySchemeReference("securitySchemeId1", __advancedOperationWithTagsAndSecurity_supportingDocument)] = [], + [new OpenApiSecuritySchemeReference("securitySchemeId2", __advancedOperationWithTagsAndSecurity_supportingDocument)] = + [ "scopeName1", "scopeName2" - } + ] } - }, - Servers = new List - { + ], + Servers = + [ new() { Url = "http://server.com", Description = "serverDescription" } - } + ] }; private static OpenApiDocument __advancedOperationWithTagsAndSecurity_supportingDocument { @@ -222,13 +222,13 @@ private static OpenApiDocument __advancedOperationWithTagsAndSecurity_supporting ], RequestBody = new OpenApiRequestBody() { - Content = + Content = new() { ["application/x-www-form-urlencoded"] = new() { Schema = new OpenApiSchema() { - Properties = + Properties = new() { ["name"] = new OpenApiSchema() { @@ -251,7 +251,7 @@ private static OpenApiDocument __advancedOperationWithTagsAndSecurity_supporting { Schema = new OpenApiSchema() { - Properties = + Properties = new() { ["name"] = new OpenApiSchema() { diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.cs index da0c00d44..a9bb4ba78 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Globalization; using System.IO; +using System.Text.Json.Nodes; using System.Threading.Tasks; using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Extensions; @@ -45,13 +46,13 @@ public class OpenApiParameterTests { Title = "title2", Description = "description2", - OneOf = new List - { + OneOf = + [ new OpenApiSchema() { Type = JsonSchemaType.Number, Format = "double" }, new OpenApiSchema() { Type = JsonSchemaType.String } - } + ] }, - Examples = + Examples = new Dictionary { ["test"] = new OpenApiExample() { @@ -74,10 +75,10 @@ public class OpenApiParameterTests Items = new OpenApiSchema() { Enum = - { + [ new OpenApiAny("value1").Node, new OpenApiAny("value2").Node - } + ] } } }; @@ -131,7 +132,7 @@ public class OpenApiParameterTests { Type = JsonSchemaType.Object }, - Examples = + Examples = new Dictionary { ["test"] = new OpenApiExample() { diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.cs index 863ce5145..8d037629b 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. +using System.Collections.Generic; using System.Globalization; using System.IO; using System.Threading.Tasks; @@ -19,7 +20,7 @@ public class OpenApiRequestBodyTests { Description = "description", Required = true, - Content = + Content = new() { ["application/json"] = new() { @@ -36,7 +37,7 @@ public class OpenApiRequestBodyTests { Description = "description", Required = true, - Content = + Content = new() { ["application/json"] = new() { diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.cs index 7d077b540..51decab10 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.cs @@ -9,6 +9,7 @@ using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; +using Microsoft.OpenApi.Models.Interfaces; using Microsoft.OpenApi.Models.References; using Microsoft.OpenApi.Writers; using VerifyXunit; @@ -25,7 +26,7 @@ public class OpenApiResponseTests private static OpenApiResponse AdvancedV2Response => new OpenApiResponse { Description = "A complex object array response", - Content = + Content = new Dictionary { ["text/plain"] = new OpenApiMediaType { @@ -35,13 +36,13 @@ public class OpenApiResponseTests Items = new OpenApiSchemaReference("customType", null) }, Example = "Blabla", - Extensions = new Dictionary + Extensions = new() { ["myextension"] = new OpenApiAny("myextensionvalue"), }, } }, - Headers = + Headers = new Dictionary { ["X-Rate-Limit-Limit"] = new OpenApiHeader { @@ -64,7 +65,7 @@ public class OpenApiResponseTests private static OpenApiResponse AdvancedV3Response => new OpenApiResponse { Description = "A complex object array response", - Content = + Content = new Dictionary { ["text/plain"] = new OpenApiMediaType { @@ -74,13 +75,13 @@ public class OpenApiResponseTests Items = new OpenApiSchemaReference("customType", null) }, Example = "Blabla", - Extensions = new Dictionary + Extensions = new() { ["myextension"] = new OpenApiAny("myextensionvalue"), }, } }, - Headers = + Headers = new Dictionary { ["X-Rate-Limit-Limit"] = new OpenApiHeader { @@ -105,7 +106,7 @@ public class OpenApiResponseTests private static OpenApiResponse ReferencedV2Response => new OpenApiResponse { Description = "A complex object array response", - Content = + Content = new Dictionary { ["text/plain"] = new OpenApiMediaType { @@ -116,7 +117,7 @@ public class OpenApiResponseTests } } }, - Headers = + Headers = new Dictionary { ["X-Rate-Limit-Limit"] = new OpenApiHeader { @@ -141,7 +142,7 @@ public class OpenApiResponseTests private static OpenApiResponse ReferencedV3Response => new OpenApiResponse { Description = "A complex object array response", - Content = + Content = new Dictionary { ["text/plain"] = new OpenApiMediaType { @@ -152,7 +153,7 @@ public class OpenApiResponseTests } } }, - Headers = + Headers = new Dictionary { ["X-Rate-Limit-Limit"] = new OpenApiHeader { diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs index bc0056c5a..6e2f00656 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs @@ -44,11 +44,11 @@ public class OpenApiSchemaTests public static readonly OpenApiSchema AdvancedSchemaObject = new() { Title = "title1", - Properties = new Dictionary + Properties = new() { ["property1"] = new OpenApiSchema() { - Properties = new Dictionary + Properties = new() { ["property2"] = new OpenApiSchema() { @@ -63,11 +63,11 @@ public class OpenApiSchemaTests }, ["property4"] = new OpenApiSchema() { - Properties = new Dictionary + Properties = new() { ["property5"] = new OpenApiSchema() { - Properties = new Dictionary + Properties = new() { ["property6"] = new OpenApiSchema() { @@ -93,12 +93,12 @@ public class OpenApiSchemaTests public static readonly OpenApiSchema AdvancedSchemaWithAllOf = new() { Title = "title1", - AllOf = new List - { + AllOf = + [ new OpenApiSchema() { Title = "title2", - Properties = new Dictionary + Properties = new() { ["property1"] = new OpenApiSchema() { @@ -114,11 +114,11 @@ public class OpenApiSchemaTests new OpenApiSchema() { Title = "title3", - Properties = new Dictionary + Properties = new() { ["property3"] = new OpenApiSchema() { - Properties = new Dictionary + Properties = new() { ["property4"] = new OpenApiSchema() { @@ -134,7 +134,7 @@ public class OpenApiSchemaTests }, Type = JsonSchemaType.Object | JsonSchemaType.Null, }, - }, + ], Type = JsonSchemaType.Object | JsonSchemaType.Null, ExternalDocs = new() { @@ -161,12 +161,12 @@ public class OpenApiSchemaTests { Title = "title1", Required = new HashSet { "property1" }, - Properties = new Dictionary + Properties = new() { ["property1"] = new OpenApiSchema() { Required = new HashSet { "property3" }, - Properties = new Dictionary + Properties = new() { ["property2"] = new OpenApiSchema() { @@ -183,11 +183,11 @@ public class OpenApiSchemaTests }, ["property4"] = new OpenApiSchema() { - Properties = new Dictionary + Properties = new() { ["property5"] = new OpenApiSchema() { - Properties = new Dictionary + Properties = new() { ["property6"] = new OpenApiSchema() { @@ -417,15 +417,15 @@ public async Task SerializeAsV2ShouldSetFormatPropertyInParentSchemaIfPresentInC // Arrange var schema = new OpenApiSchema { - OneOf = new List - { + OneOf = + [ new OpenApiSchema() { Type = JsonSchemaType.Number, Format = "decimal" }, new OpenApiSchema() { Type = JsonSchemaType.String }, - } + ] }; var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); @@ -536,7 +536,7 @@ public void CloningSchemaExtensionsWorks() // Arrange var schema = new OpenApiSchema { - Extensions = + Extensions = new() { { "x-myextension", new OpenApiAny(42) } } @@ -547,7 +547,7 @@ public void CloningSchemaExtensionsWorks() Assert.Single(schemaCopy.Extensions); // Act && Assert - schemaCopy.Extensions = new Dictionary + schemaCopy.Extensions = new() { { "x-myextension" , new OpenApiAny(40) } }; @@ -573,15 +573,15 @@ public void OpenApiWalkerVisitsOpenApiSchemaNot() { ["/foo"] = new OpenApiPathItem() { - Parameters = new[] - { + Parameters = + [ new OpenApiParameter() { Name = "foo", In = ParameterLocation.Query, Schema = outerSchema, } - } + ] } } }; diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.cs index 73ac0d0b7..2cb7f1da6 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.cs @@ -25,7 +25,7 @@ public class OpenApiTagTests Name = "pet", Description = "Pets operations", ExternalDocs = OpenApiExternalDocsTests.AdvanceExDocs, - Extensions = new Dictionary + Extensions = new() { {"x-tag-extension", null} } diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiXmlTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiXmlTests.cs index 9ff3569d4..98ec758c8 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiXmlTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiXmlTests.cs @@ -21,7 +21,7 @@ public class OpenApiXmlTests Prefix = "sample", Wrapped = true, Attribute = true, - Extensions = new Dictionary + Extensions = new() { {"x-xml-extension", new OpenApiAny(7)} } diff --git a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiHeaderReferenceTests.cs b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiHeaderReferenceTests.cs index 9da36b512..02a7308a3 100644 --- a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiHeaderReferenceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiHeaderReferenceTests.cs @@ -12,6 +12,8 @@ using Microsoft.OpenApi.Writers; using VerifyXunit; using Xunit; +using System.Collections.Generic; +using Microsoft.OpenApi.Models.Interfaces; namespace Microsoft.OpenApi.Tests.Models.References { @@ -171,7 +173,7 @@ public void OpenApiHeaderTargetShouldResolveReference() { Components = new OpenApiComponents { - Headers = + Headers = new Dictionary { { "header1", new OpenApiHeader { diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index 140cfd46c..bcec5fb01 100644 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -183,7 +183,7 @@ namespace Microsoft.OpenApi.Extensions } public static class OpenApiServerExtensions { - public static string? ReplaceServerUrlVariables(this Microsoft.OpenApi.Models.OpenApiServer server, System.Collections.Generic.IDictionary? values = null) { } + public static string? ReplaceServerUrlVariables(this Microsoft.OpenApi.Models.OpenApiServer server, System.Collections.Generic.Dictionary? values = null) { } } public static class OpenApiTypeMapper { @@ -200,12 +200,12 @@ namespace Microsoft.OpenApi.Interfaces public interface IDiagnostic { } public interface IMetadataContainer { - System.Collections.Generic.IDictionary? Metadata { get; set; } + System.Collections.Generic.Dictionary? Metadata { get; set; } } public interface IOpenApiElement { } public interface IOpenApiExtensible : Microsoft.OpenApi.Interfaces.IOpenApiElement { - System.Collections.Generic.IDictionary? Extensions { get; set; } + System.Collections.Generic.Dictionary? Extensions { get; set; } } public interface IOpenApiExtension { @@ -213,7 +213,7 @@ namespace Microsoft.OpenApi.Interfaces } public interface IOpenApiReadOnlyExtensible { - System.Collections.Generic.IDictionary? Extensions { get; } + System.Collections.Generic.Dictionary? Extensions { get; } } public interface IOpenApiReader { @@ -355,10 +355,10 @@ namespace Microsoft.OpenApi.Models.Interfaces { bool AllowEmptyValue { get; } bool AllowReserved { get; } - System.Collections.Generic.IDictionary? Content { get; } + System.Collections.Generic.Dictionary? Content { get; } bool Deprecated { get; } System.Text.Json.Nodes.JsonNode? Example { get; } - System.Collections.Generic.IDictionary? Examples { get; } + System.Collections.Generic.Dictionary? Examples { get; } bool Explode { get; } bool Required { get; } Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema? Schema { get; } @@ -368,7 +368,7 @@ namespace Microsoft.OpenApi.Models.Interfaces { string? OperationId { get; } string? OperationRef { get; } - System.Collections.Generic.IDictionary? Parameters { get; } + System.Collections.Generic.Dictionary? Parameters { get; } Microsoft.OpenApi.Models.RuntimeExpressionAnyWrapper? RequestBody { get; } Microsoft.OpenApi.Models.OpenApiServer? Server { get; } } @@ -376,10 +376,10 @@ namespace Microsoft.OpenApi.Models.Interfaces { bool AllowEmptyValue { get; } bool AllowReserved { get; } - System.Collections.Generic.IDictionary? Content { get; } + System.Collections.Generic.Dictionary? Content { get; } bool Deprecated { get; } System.Text.Json.Nodes.JsonNode? Example { get; } - System.Collections.Generic.IDictionary? Examples { get; } + System.Collections.Generic.Dictionary? Examples { get; } bool Explode { get; } Microsoft.OpenApi.Models.ParameterLocation? In { get; } string? Name { get; } @@ -389,9 +389,9 @@ namespace Microsoft.OpenApi.Models.Interfaces } public interface IOpenApiPathItem : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiSummarizedElement { - System.Collections.Generic.IDictionary? Operations { get; } - System.Collections.Generic.IList? Parameters { get; } - System.Collections.Generic.IList? Servers { get; } + System.Collections.Generic.Dictionary? Operations { get; } + System.Collections.Generic.List? Parameters { get; } + System.Collections.Generic.List? Servers { get; } } public interface IOpenApiReadOnlyDescribedElement : Microsoft.OpenApi.Interfaces.IOpenApiElement { @@ -399,36 +399,36 @@ namespace Microsoft.OpenApi.Models.Interfaces } public interface IOpenApiRequestBody : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement { - System.Collections.Generic.IDictionary? Content { get; } + System.Collections.Generic.Dictionary? Content { get; } bool Required { get; } Microsoft.OpenApi.Models.Interfaces.IOpenApiParameter? ConvertToBodyParameter(Microsoft.OpenApi.Writers.IOpenApiWriter writer); System.Collections.Generic.IEnumerable? ConvertToFormDataParameters(Microsoft.OpenApi.Writers.IOpenApiWriter writer); } public interface IOpenApiResponse : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement { - System.Collections.Generic.IDictionary? Content { get; } - System.Collections.Generic.IDictionary? Headers { get; } - System.Collections.Generic.IDictionary? Links { get; } + System.Collections.Generic.Dictionary? Content { get; } + System.Collections.Generic.Dictionary? Headers { get; } + System.Collections.Generic.Dictionary? Links { get; } } public interface IOpenApiSchema : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement { Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema? AdditionalProperties { get; } bool AdditionalPropertiesAllowed { get; } - System.Collections.Generic.IList? AllOf { get; } - System.Collections.Generic.IDictionary? Annotations { get; } - System.Collections.Generic.IList? AnyOf { get; } + System.Collections.Generic.List? AllOf { get; } + System.Collections.Generic.Dictionary? Annotations { get; } + System.Collections.Generic.List? AnyOf { get; } string? Comment { get; } string? Const { get; } System.Text.Json.Nodes.JsonNode? Default { get; } - System.Collections.Generic.IDictionary? Definitions { get; } - System.Collections.Generic.IDictionary>? DependentRequired { get; } + System.Collections.Generic.Dictionary? Definitions { get; } + System.Collections.Generic.Dictionary>? DependentRequired { get; } bool Deprecated { get; } Microsoft.OpenApi.Models.OpenApiDiscriminator? Discriminator { get; } string? DynamicAnchor { get; } string? DynamicRef { get; } - System.Collections.Generic.IList? Enum { get; } + System.Collections.Generic.List? Enum { get; } System.Text.Json.Nodes.JsonNode? Example { get; } - System.Collections.Generic.IList? Examples { get; } + System.Collections.Generic.List? Examples { get; } string? ExclusiveMaximum { get; } string? ExclusiveMinimum { get; } Microsoft.OpenApi.Models.OpenApiExternalDocs? ExternalDocs { get; } @@ -445,19 +445,19 @@ namespace Microsoft.OpenApi.Models.Interfaces string? Minimum { get; } decimal? MultipleOf { get; } Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema? Not { get; } - System.Collections.Generic.IList? OneOf { get; } + System.Collections.Generic.List? OneOf { get; } string? Pattern { get; } - System.Collections.Generic.IDictionary? PatternProperties { get; } - System.Collections.Generic.IDictionary? Properties { get; } + System.Collections.Generic.Dictionary? PatternProperties { get; } + System.Collections.Generic.Dictionary? Properties { get; } bool ReadOnly { get; } - System.Collections.Generic.ISet? Required { get; } + System.Collections.Generic.HashSet? Required { get; } System.Uri? Schema { get; } string? Title { get; } Microsoft.OpenApi.Models.JsonSchemaType? Type { get; } bool UnevaluatedProperties { get; } bool? UniqueItems { get; } - System.Collections.Generic.IDictionary? UnrecognizedKeywords { get; } - System.Collections.Generic.IDictionary? Vocabulary { get; } + System.Collections.Generic.Dictionary? UnrecognizedKeywords { get; } + System.Collections.Generic.Dictionary? Vocabulary { get; } bool WriteOnly { get; } Microsoft.OpenApi.Models.OpenApiXml? Xml { get; } } @@ -497,7 +497,7 @@ namespace Microsoft.OpenApi.Models public class OpenApiCallback : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiCallback { public OpenApiCallback() { } - public System.Collections.Generic.IDictionary? Extensions { get; set; } + public System.Collections.Generic.Dictionary? Extensions { get; set; } public System.Collections.Generic.Dictionary? PathItems { get; set; } public void AddPathItem(Microsoft.OpenApi.Expressions.RuntimeExpression expression, Microsoft.OpenApi.Models.Interfaces.IOpenApiPathItem pathItem) { } public Microsoft.OpenApi.Models.Interfaces.IOpenApiCallback CreateShallowCopy() { } @@ -509,17 +509,17 @@ namespace Microsoft.OpenApi.Models { public OpenApiComponents() { } public OpenApiComponents(Microsoft.OpenApi.Models.OpenApiComponents? components) { } - public System.Collections.Generic.IDictionary? Callbacks { get; set; } - public System.Collections.Generic.IDictionary? Examples { get; set; } - public System.Collections.Generic.IDictionary? Extensions { get; set; } - public System.Collections.Generic.IDictionary? Headers { get; set; } - public System.Collections.Generic.IDictionary? Links { get; set; } - public System.Collections.Generic.IDictionary? Parameters { get; set; } - public System.Collections.Generic.IDictionary? PathItems { get; set; } - public System.Collections.Generic.IDictionary? RequestBodies { get; set; } - public System.Collections.Generic.IDictionary? Responses { get; set; } - public System.Collections.Generic.IDictionary? Schemas { get; set; } - public System.Collections.Generic.IDictionary? SecuritySchemes { get; set; } + public System.Collections.Generic.Dictionary? Callbacks { get; set; } + public System.Collections.Generic.Dictionary? Examples { get; set; } + public System.Collections.Generic.Dictionary? Extensions { get; set; } + public System.Collections.Generic.Dictionary? Headers { get; set; } + public System.Collections.Generic.Dictionary? Links { get; set; } + public System.Collections.Generic.Dictionary? Parameters { get; set; } + public System.Collections.Generic.Dictionary? PathItems { get; set; } + public System.Collections.Generic.Dictionary? RequestBodies { get; set; } + public System.Collections.Generic.Dictionary? Responses { get; set; } + public System.Collections.Generic.Dictionary? Schemas { get; set; } + public System.Collections.Generic.Dictionary? SecuritySchemes { get; set; } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -687,7 +687,7 @@ namespace Microsoft.OpenApi.Models public OpenApiContact() { } public OpenApiContact(Microsoft.OpenApi.Models.OpenApiContact contact) { } public string? Email { get; set; } - public System.Collections.Generic.IDictionary? Extensions { get; set; } + public System.Collections.Generic.Dictionary? Extensions { get; set; } public string? Name { get; set; } public System.Uri? Url { get; set; } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -698,8 +698,8 @@ namespace Microsoft.OpenApi.Models { public OpenApiDiscriminator() { } public OpenApiDiscriminator(Microsoft.OpenApi.Models.OpenApiDiscriminator discriminator) { } - public System.Collections.Generic.IDictionary? Extensions { get; set; } - public System.Collections.Generic.IDictionary? Mapping { get; set; } + public System.Collections.Generic.Dictionary? Extensions { get; set; } + public System.Collections.Generic.Dictionary? Mapping { get; set; } public string? PropertyName { get; set; } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -711,16 +711,16 @@ namespace Microsoft.OpenApi.Models public OpenApiDocument(Microsoft.OpenApi.Models.OpenApiDocument? document) { } public System.Uri BaseUri { get; } public Microsoft.OpenApi.Models.OpenApiComponents? Components { get; set; } - public System.Collections.Generic.IDictionary? Extensions { get; set; } + public System.Collections.Generic.Dictionary? Extensions { get; set; } public Microsoft.OpenApi.Models.OpenApiExternalDocs? ExternalDocs { get; set; } public Microsoft.OpenApi.Models.OpenApiInfo Info { get; set; } public System.Uri? JsonSchemaDialect { get; set; } - public System.Collections.Generic.IDictionary? Metadata { get; set; } + public System.Collections.Generic.Dictionary? Metadata { get; set; } public Microsoft.OpenApi.Models.OpenApiPaths Paths { get; set; } - public System.Collections.Generic.IList? Security { get; set; } - public System.Collections.Generic.IList? Servers { get; set; } - public System.Collections.Generic.ISet? Tags { get; set; } - public System.Collections.Generic.IDictionary? Webhooks { get; set; } + public System.Collections.Generic.List? Security { get; set; } + public System.Collections.Generic.List? Servers { get; set; } + public System.Collections.Generic.HashSet? Tags { get; set; } + public System.Collections.Generic.Dictionary? Webhooks { get; set; } public Microsoft.OpenApi.Services.OpenApiWorkspace? Workspace { get; set; } public bool AddComponent(string id, T componentToRegister) { } public System.Threading.Tasks.Task GetHashCodeAsync(System.Threading.CancellationToken cancellationToken = default) { } @@ -742,8 +742,8 @@ namespace Microsoft.OpenApi.Models public bool? AllowReserved { get; set; } public string? ContentType { get; set; } public bool? Explode { get; set; } - public System.Collections.Generic.IDictionary? Extensions { get; set; } - public System.Collections.Generic.IDictionary? Headers { get; set; } + public System.Collections.Generic.Dictionary? Extensions { get; set; } + public System.Collections.Generic.Dictionary? Headers { get; set; } public Microsoft.OpenApi.Models.ParameterStyle? Style { get; set; } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -762,7 +762,7 @@ namespace Microsoft.OpenApi.Models { public OpenApiExample() { } public string? Description { get; set; } - public System.Collections.Generic.IDictionary? Extensions { get; set; } + public System.Collections.Generic.Dictionary? Extensions { get; set; } public string? ExternalValue { get; set; } public string? Summary { get; set; } public System.Text.Json.Nodes.JsonNode? Value { get; set; } @@ -775,8 +775,8 @@ namespace Microsoft.OpenApi.Models where T : Microsoft.OpenApi.Interfaces.IOpenApiSerializable { protected OpenApiExtensibleDictionary() { } - protected OpenApiExtensibleDictionary(System.Collections.Generic.Dictionary dictionary, System.Collections.Generic.IDictionary? extensions = null) { } - public System.Collections.Generic.IDictionary? Extensions { get; set; } + protected OpenApiExtensibleDictionary(System.Collections.Generic.Dictionary dictionary, System.Collections.Generic.Dictionary? extensions = null) { } + public System.Collections.Generic.Dictionary? Extensions { get; set; } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -786,7 +786,7 @@ namespace Microsoft.OpenApi.Models public OpenApiExternalDocs() { } public OpenApiExternalDocs(Microsoft.OpenApi.Models.OpenApiExternalDocs externalDocs) { } public string? Description { get; set; } - public System.Collections.Generic.IDictionary? Extensions { get; set; } + public System.Collections.Generic.Dictionary? Extensions { get; set; } public System.Uri? Url { get; set; } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -797,13 +797,13 @@ namespace Microsoft.OpenApi.Models public OpenApiHeader() { } public bool AllowEmptyValue { get; set; } public bool AllowReserved { get; set; } - public System.Collections.Generic.IDictionary? Content { get; set; } + public System.Collections.Generic.Dictionary? Content { get; set; } public bool Deprecated { get; set; } public string? Description { get; set; } public System.Text.Json.Nodes.JsonNode? Example { get; set; } - public System.Collections.Generic.IDictionary? Examples { get; set; } + public System.Collections.Generic.Dictionary? Examples { get; set; } public bool Explode { get; set; } - public System.Collections.Generic.IDictionary? Extensions { get; set; } + public System.Collections.Generic.Dictionary? Extensions { get; set; } public bool Required { get; set; } public Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema? Schema { get; set; } public Microsoft.OpenApi.Models.ParameterStyle? Style { get; set; } @@ -818,7 +818,7 @@ namespace Microsoft.OpenApi.Models public OpenApiInfo(Microsoft.OpenApi.Models.OpenApiInfo info) { } public Microsoft.OpenApi.Models.OpenApiContact? Contact { get; set; } public string? Description { get; set; } - public System.Collections.Generic.IDictionary? Extensions { get; set; } + public System.Collections.Generic.Dictionary? Extensions { get; set; } public Microsoft.OpenApi.Models.OpenApiLicense? License { get; set; } public string? Summary { get; set; } public System.Uri? TermsOfService { get; set; } @@ -832,7 +832,7 @@ namespace Microsoft.OpenApi.Models { public OpenApiLicense() { } public OpenApiLicense(Microsoft.OpenApi.Models.OpenApiLicense license) { } - public System.Collections.Generic.IDictionary? Extensions { get; set; } + public System.Collections.Generic.Dictionary? Extensions { get; set; } public string? Identifier { get; set; } public string? Name { get; set; } public System.Uri? Url { get; set; } @@ -844,10 +844,10 @@ namespace Microsoft.OpenApi.Models { public OpenApiLink() { } public string? Description { get; set; } - public System.Collections.Generic.IDictionary? Extensions { get; set; } + public System.Collections.Generic.Dictionary? Extensions { get; set; } public string? OperationId { get; set; } public string? OperationRef { get; set; } - public System.Collections.Generic.IDictionary? Parameters { get; set; } + public System.Collections.Generic.Dictionary? Parameters { get; set; } public Microsoft.OpenApi.Models.RuntimeExpressionAnyWrapper? RequestBody { get; set; } public Microsoft.OpenApi.Models.OpenApiServer? Server { get; set; } public Microsoft.OpenApi.Models.Interfaces.IOpenApiLink CreateShallowCopy() { } @@ -859,10 +859,10 @@ namespace Microsoft.OpenApi.Models { public OpenApiMediaType() { } public OpenApiMediaType(Microsoft.OpenApi.Models.OpenApiMediaType? mediaType) { } - public System.Collections.Generic.IDictionary? Encoding { get; set; } + public System.Collections.Generic.Dictionary? Encoding { get; set; } public System.Text.Json.Nodes.JsonNode? Example { get; set; } - public System.Collections.Generic.IDictionary? Examples { get; set; } - public System.Collections.Generic.IDictionary? Extensions { get; set; } + public System.Collections.Generic.Dictionary? Examples { get; set; } + public System.Collections.Generic.Dictionary? Extensions { get; set; } public Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema? Schema { get; set; } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -873,9 +873,9 @@ namespace Microsoft.OpenApi.Models public OpenApiOAuthFlow() { } public OpenApiOAuthFlow(Microsoft.OpenApi.Models.OpenApiOAuthFlow oAuthFlow) { } public System.Uri? AuthorizationUrl { get; set; } - public System.Collections.Generic.IDictionary? Extensions { get; set; } + public System.Collections.Generic.Dictionary? Extensions { get; set; } public System.Uri? RefreshUrl { get; set; } - public System.Collections.Generic.IDictionary? Scopes { get; set; } + public System.Collections.Generic.Dictionary? Scopes { get; set; } public System.Uri? TokenUrl { get; set; } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -887,7 +887,7 @@ namespace Microsoft.OpenApi.Models public OpenApiOAuthFlows(Microsoft.OpenApi.Models.OpenApiOAuthFlows oAuthFlows) { } public Microsoft.OpenApi.Models.OpenApiOAuthFlow? AuthorizationCode { get; set; } public Microsoft.OpenApi.Models.OpenApiOAuthFlow? ClientCredentials { get; set; } - public System.Collections.Generic.IDictionary? Extensions { get; set; } + public System.Collections.Generic.Dictionary? Extensions { get; set; } public Microsoft.OpenApi.Models.OpenApiOAuthFlow? Implicit { get; set; } public Microsoft.OpenApi.Models.OpenApiOAuthFlow? Password { get; set; } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -899,20 +899,20 @@ namespace Microsoft.OpenApi.Models public const bool DeprecatedDefault = false; public OpenApiOperation() { } public OpenApiOperation(Microsoft.OpenApi.Models.OpenApiOperation operation) { } - public System.Collections.Generic.IDictionary? Callbacks { get; set; } + public System.Collections.Generic.Dictionary? Callbacks { get; set; } public bool Deprecated { get; set; } public string? Description { get; set; } - public System.Collections.Generic.IDictionary? Extensions { get; set; } + public System.Collections.Generic.Dictionary? Extensions { get; set; } public Microsoft.OpenApi.Models.OpenApiExternalDocs? ExternalDocs { get; set; } - public System.Collections.Generic.IDictionary? Metadata { get; set; } + public System.Collections.Generic.Dictionary? Metadata { get; set; } public string? OperationId { get; set; } - public System.Collections.Generic.IList? Parameters { get; set; } + public System.Collections.Generic.List? Parameters { get; set; } public Microsoft.OpenApi.Models.Interfaces.IOpenApiRequestBody? RequestBody { get; set; } public Microsoft.OpenApi.Models.OpenApiResponses? Responses { get; set; } - public System.Collections.Generic.IList? Security { get; set; } - public System.Collections.Generic.IList? Servers { get; set; } + public System.Collections.Generic.List? Security { get; set; } + public System.Collections.Generic.List? Servers { get; set; } public string? Summary { get; set; } - public System.Collections.Generic.ISet? Tags { get; set; } + public System.Collections.Generic.HashSet? Tags { get; set; } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -922,13 +922,13 @@ namespace Microsoft.OpenApi.Models public OpenApiParameter() { } public bool AllowEmptyValue { get; set; } public bool AllowReserved { get; set; } - public System.Collections.Generic.IDictionary? Content { get; set; } + public System.Collections.Generic.Dictionary? Content { get; set; } public bool Deprecated { get; set; } public string? Description { get; set; } public System.Text.Json.Nodes.JsonNode? Example { get; set; } - public System.Collections.Generic.IDictionary? Examples { get; set; } + public System.Collections.Generic.Dictionary? Examples { get; set; } public bool Explode { get; set; } - public System.Collections.Generic.IDictionary? Extensions { get; set; } + public System.Collections.Generic.Dictionary? Extensions { get; set; } public Microsoft.OpenApi.Models.ParameterLocation? In { get; set; } public string? Name { get; set; } public bool Required { get; set; } @@ -943,10 +943,10 @@ namespace Microsoft.OpenApi.Models { public OpenApiPathItem() { } public string? Description { get; set; } - public System.Collections.Generic.IDictionary? Extensions { get; set; } - public System.Collections.Generic.IDictionary? Operations { get; set; } - public System.Collections.Generic.IList? Parameters { get; set; } - public System.Collections.Generic.IList? Servers { get; set; } + public System.Collections.Generic.Dictionary? Extensions { get; set; } + public System.Collections.Generic.Dictionary? Operations { get; set; } + public System.Collections.Generic.List? Parameters { get; set; } + public System.Collections.Generic.List? Servers { get; set; } public string? Summary { get; set; } public void AddOperation(System.Net.Http.HttpMethod operationType, Microsoft.OpenApi.Models.OpenApiOperation operation) { } public Microsoft.OpenApi.Models.Interfaces.IOpenApiPathItem CreateShallowCopy() { } @@ -981,9 +981,9 @@ namespace Microsoft.OpenApi.Models public class OpenApiRequestBody : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiRequestBody { public OpenApiRequestBody() { } - public System.Collections.Generic.IDictionary? Content { get; set; } + public System.Collections.Generic.Dictionary? Content { get; set; } public string? Description { get; set; } - public System.Collections.Generic.IDictionary? Extensions { get; set; } + public System.Collections.Generic.Dictionary? Extensions { get; set; } public bool Required { get; set; } public Microsoft.OpenApi.Models.Interfaces.IOpenApiParameter ConvertToBodyParameter(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public System.Collections.Generic.IEnumerable ConvertToFormDataParameters(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -995,11 +995,11 @@ namespace Microsoft.OpenApi.Models public class OpenApiResponse : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiResponse { public OpenApiResponse() { } - public System.Collections.Generic.IDictionary? Content { get; set; } + public System.Collections.Generic.Dictionary? Content { get; set; } public string? Description { get; set; } - public System.Collections.Generic.IDictionary? Extensions { get; set; } - public System.Collections.Generic.IDictionary? Headers { get; set; } - public System.Collections.Generic.IDictionary? Links { get; set; } + public System.Collections.Generic.Dictionary? Extensions { get; set; } + public System.Collections.Generic.Dictionary? Headers { get; set; } + public System.Collections.Generic.Dictionary? Links { get; set; } public Microsoft.OpenApi.Models.Interfaces.IOpenApiResponse CreateShallowCopy() { } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -1015,25 +1015,25 @@ namespace Microsoft.OpenApi.Models public OpenApiSchema() { } public Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema? AdditionalProperties { get; set; } public bool AdditionalPropertiesAllowed { get; set; } - public System.Collections.Generic.IList? AllOf { get; set; } - public System.Collections.Generic.IDictionary? Annotations { get; set; } - public System.Collections.Generic.IList? AnyOf { get; set; } + public System.Collections.Generic.List? AllOf { get; set; } + public System.Collections.Generic.Dictionary? Annotations { get; set; } + public System.Collections.Generic.List? AnyOf { get; set; } public string? Comment { get; set; } public string? Const { get; set; } public System.Text.Json.Nodes.JsonNode? Default { get; set; } - public System.Collections.Generic.IDictionary? Definitions { get; set; } - public System.Collections.Generic.IDictionary>? DependentRequired { get; set; } + public System.Collections.Generic.Dictionary? Definitions { get; set; } + public System.Collections.Generic.Dictionary>? DependentRequired { get; set; } public bool Deprecated { get; set; } public string? Description { get; set; } public Microsoft.OpenApi.Models.OpenApiDiscriminator? Discriminator { get; set; } public string? DynamicAnchor { get; set; } public string? DynamicRef { get; set; } - public System.Collections.Generic.IList? Enum { get; set; } + public System.Collections.Generic.List? Enum { get; set; } public System.Text.Json.Nodes.JsonNode? Example { get; set; } - public System.Collections.Generic.IList? Examples { get; set; } + public System.Collections.Generic.List? Examples { get; set; } public string? ExclusiveMaximum { get; set; } public string? ExclusiveMinimum { get; set; } - public System.Collections.Generic.IDictionary? Extensions { get; set; } + public System.Collections.Generic.Dictionary? Extensions { get; set; } public Microsoft.OpenApi.Models.OpenApiExternalDocs? ExternalDocs { get; set; } public string? Format { get; set; } public string? Id { get; set; } @@ -1048,19 +1048,19 @@ namespace Microsoft.OpenApi.Models public string? Minimum { get; set; } public decimal? MultipleOf { get; set; } public Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema? Not { get; set; } - public System.Collections.Generic.IList? OneOf { get; set; } + public System.Collections.Generic.List? OneOf { get; set; } public string? Pattern { get; set; } - public System.Collections.Generic.IDictionary? PatternProperties { get; set; } - public System.Collections.Generic.IDictionary? Properties { get; set; } + public System.Collections.Generic.Dictionary? PatternProperties { get; set; } + public System.Collections.Generic.Dictionary? Properties { get; set; } public bool ReadOnly { get; set; } - public System.Collections.Generic.ISet? Required { get; set; } + public System.Collections.Generic.HashSet? Required { get; set; } public System.Uri? Schema { get; set; } public string? Title { get; set; } public Microsoft.OpenApi.Models.JsonSchemaType? Type { get; set; } public bool UnevaluatedProperties { get; set; } public bool? UniqueItems { get; set; } - public System.Collections.Generic.IDictionary? UnrecognizedKeywords { get; set; } - public System.Collections.Generic.IDictionary? Vocabulary { get; set; } + public System.Collections.Generic.Dictionary? UnrecognizedKeywords { get; set; } + public System.Collections.Generic.Dictionary? Vocabulary { get; set; } public bool WriteOnly { get; set; } public Microsoft.OpenApi.Models.OpenApiXml? Xml { get; set; } public Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema CreateShallowCopy() { } @@ -1068,7 +1068,7 @@ namespace Microsoft.OpenApi.Models public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } } - public class OpenApiSecurityRequirement : System.Collections.Generic.Dictionary>, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiSerializable + public class OpenApiSecurityRequirement : System.Collections.Generic.Dictionary>, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { public OpenApiSecurityRequirement() { } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -1080,7 +1080,7 @@ namespace Microsoft.OpenApi.Models public OpenApiSecurityScheme() { } public string? BearerFormat { get; set; } public string? Description { get; set; } - public System.Collections.Generic.IDictionary? Extensions { get; set; } + public System.Collections.Generic.Dictionary? Extensions { get; set; } public Microsoft.OpenApi.Models.OpenApiOAuthFlows? Flows { get; set; } public Microsoft.OpenApi.Models.ParameterLocation? In { get; set; } public string? Name { get; set; } @@ -1097,9 +1097,9 @@ namespace Microsoft.OpenApi.Models public OpenApiServer() { } public OpenApiServer(Microsoft.OpenApi.Models.OpenApiServer server) { } public string? Description { get; set; } - public System.Collections.Generic.IDictionary? Extensions { get; set; } + public System.Collections.Generic.Dictionary? Extensions { get; set; } public string? Url { get; set; } - public System.Collections.Generic.IDictionary? Variables { get; set; } + public System.Collections.Generic.Dictionary? Variables { get; set; } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -1111,7 +1111,7 @@ namespace Microsoft.OpenApi.Models public string? Default { get; set; } public string? Description { get; set; } public System.Collections.Generic.List? Enum { get; set; } - public System.Collections.Generic.IDictionary? Extensions { get; set; } + public System.Collections.Generic.Dictionary? Extensions { get; set; } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -1120,7 +1120,7 @@ namespace Microsoft.OpenApi.Models { public OpenApiTag() { } public string? Description { get; set; } - public System.Collections.Generic.IDictionary? Extensions { get; set; } + public System.Collections.Generic.Dictionary? Extensions { get; set; } public Microsoft.OpenApi.Models.OpenApiExternalDocs? ExternalDocs { get; set; } public string? Name { get; set; } public Microsoft.OpenApi.Models.Interfaces.IOpenApiTag CreateShallowCopy() { } @@ -1133,7 +1133,7 @@ namespace Microsoft.OpenApi.Models public OpenApiXml() { } public OpenApiXml(Microsoft.OpenApi.Models.OpenApiXml xml) { } public bool Attribute { get; set; } - public System.Collections.Generic.IDictionary? Extensions { get; set; } + public System.Collections.Generic.Dictionary? Extensions { get; set; } public string? Name { get; set; } public System.Uri? Namespace { get; set; } public string? Prefix { get; set; } @@ -1235,7 +1235,7 @@ namespace Microsoft.OpenApi.Models.References public class OpenApiCallbackReference : Microsoft.OpenApi.Models.References.BaseOpenApiReferenceHolder, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiCallback { public OpenApiCallbackReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument? hostDocument = null, string? externalResource = null) { } - public System.Collections.Generic.IDictionary? Extensions { get; } + public System.Collections.Generic.Dictionary? Extensions { get; } public System.Collections.Generic.Dictionary? PathItems { get; } public override Microsoft.OpenApi.Models.Interfaces.IOpenApiCallback CopyReferenceAsTargetElementWithOverrides(Microsoft.OpenApi.Models.Interfaces.IOpenApiCallback source) { } public Microsoft.OpenApi.Models.Interfaces.IOpenApiCallback CreateShallowCopy() { } @@ -1245,7 +1245,7 @@ namespace Microsoft.OpenApi.Models.References { public OpenApiExampleReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument? hostDocument = null, string? externalResource = null) { } public string? Description { get; set; } - public System.Collections.Generic.IDictionary? Extensions { get; } + public System.Collections.Generic.Dictionary? Extensions { get; } public string? ExternalValue { get; } public string? Summary { get; set; } public System.Text.Json.Nodes.JsonNode? Value { get; } @@ -1258,13 +1258,13 @@ namespace Microsoft.OpenApi.Models.References public OpenApiHeaderReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument? hostDocument = null, string? externalResource = null) { } public bool AllowEmptyValue { get; } public bool AllowReserved { get; } - public System.Collections.Generic.IDictionary? Content { get; } + public System.Collections.Generic.Dictionary? Content { get; } public bool Deprecated { get; } public string? Description { get; set; } public System.Text.Json.Nodes.JsonNode? Example { get; } - public System.Collections.Generic.IDictionary? Examples { get; } + public System.Collections.Generic.Dictionary? Examples { get; } public bool Explode { get; } - public System.Collections.Generic.IDictionary? Extensions { get; } + public System.Collections.Generic.Dictionary? Extensions { get; } public bool Required { get; } public Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema? Schema { get; } public Microsoft.OpenApi.Models.ParameterStyle? Style { get; } @@ -1275,10 +1275,10 @@ namespace Microsoft.OpenApi.Models.References { public OpenApiLinkReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument? hostDocument = null, string? externalResource = null) { } public string? Description { get; set; } - public System.Collections.Generic.IDictionary? Extensions { get; } + public System.Collections.Generic.Dictionary? Extensions { get; } public string? OperationId { get; } public string? OperationRef { get; } - public System.Collections.Generic.IDictionary? Parameters { get; } + public System.Collections.Generic.Dictionary? Parameters { get; } public Microsoft.OpenApi.Models.RuntimeExpressionAnyWrapper? RequestBody { get; } public Microsoft.OpenApi.Models.OpenApiServer? Server { get; } public override Microsoft.OpenApi.Models.Interfaces.IOpenApiLink CopyReferenceAsTargetElementWithOverrides(Microsoft.OpenApi.Models.Interfaces.IOpenApiLink source) { } @@ -1290,13 +1290,13 @@ namespace Microsoft.OpenApi.Models.References public OpenApiParameterReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument? hostDocument = null, string? externalResource = null) { } public bool AllowEmptyValue { get; } public bool AllowReserved { get; } - public System.Collections.Generic.IDictionary? Content { get; } + public System.Collections.Generic.Dictionary? Content { get; } public bool Deprecated { get; } public string? Description { get; set; } public System.Text.Json.Nodes.JsonNode? Example { get; } - public System.Collections.Generic.IDictionary? Examples { get; } + public System.Collections.Generic.Dictionary? Examples { get; } public bool Explode { get; } - public System.Collections.Generic.IDictionary? Extensions { get; } + public System.Collections.Generic.Dictionary? Extensions { get; } public Microsoft.OpenApi.Models.ParameterLocation? In { get; } public string? Name { get; } public bool Required { get; } @@ -1309,10 +1309,10 @@ namespace Microsoft.OpenApi.Models.References { public OpenApiPathItemReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument? hostDocument = null, string? externalResource = null) { } public string? Description { get; set; } - public System.Collections.Generic.IDictionary? Extensions { get; } - public System.Collections.Generic.IDictionary? Operations { get; } - public System.Collections.Generic.IList? Parameters { get; } - public System.Collections.Generic.IList? Servers { get; } + public System.Collections.Generic.Dictionary? Extensions { get; } + public System.Collections.Generic.Dictionary? Operations { get; } + public System.Collections.Generic.List? Parameters { get; } + public System.Collections.Generic.List? Servers { get; } public string? Summary { get; set; } public override Microsoft.OpenApi.Models.Interfaces.IOpenApiPathItem CopyReferenceAsTargetElementWithOverrides(Microsoft.OpenApi.Models.Interfaces.IOpenApiPathItem source) { } public Microsoft.OpenApi.Models.Interfaces.IOpenApiPathItem CreateShallowCopy() { } @@ -1321,9 +1321,9 @@ namespace Microsoft.OpenApi.Models.References public class OpenApiRequestBodyReference : Microsoft.OpenApi.Models.References.BaseOpenApiReferenceHolder, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiRequestBody { public OpenApiRequestBodyReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument? hostDocument = null, string? externalResource = null) { } - public System.Collections.Generic.IDictionary? Content { get; } + public System.Collections.Generic.Dictionary? Content { get; } public string? Description { get; set; } - public System.Collections.Generic.IDictionary? Extensions { get; } + public System.Collections.Generic.Dictionary? Extensions { get; } public bool Required { get; } public Microsoft.OpenApi.Models.Interfaces.IOpenApiParameter? ConvertToBodyParameter(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public System.Collections.Generic.IEnumerable? ConvertToFormDataParameters(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -1334,11 +1334,11 @@ namespace Microsoft.OpenApi.Models.References public class OpenApiResponseReference : Microsoft.OpenApi.Models.References.BaseOpenApiReferenceHolder, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiResponse { public OpenApiResponseReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument? hostDocument = null, string? externalResource = null) { } - public System.Collections.Generic.IDictionary? Content { get; } + public System.Collections.Generic.Dictionary? Content { get; } public string? Description { get; set; } - public System.Collections.Generic.IDictionary? Extensions { get; } - public System.Collections.Generic.IDictionary? Headers { get; } - public System.Collections.Generic.IDictionary? Links { get; } + public System.Collections.Generic.Dictionary? Extensions { get; } + public System.Collections.Generic.Dictionary? Headers { get; } + public System.Collections.Generic.Dictionary? Links { get; } public override Microsoft.OpenApi.Models.Interfaces.IOpenApiResponse CopyReferenceAsTargetElementWithOverrides(Microsoft.OpenApi.Models.Interfaces.IOpenApiResponse source) { } public Microsoft.OpenApi.Models.Interfaces.IOpenApiResponse CreateShallowCopy() { } } @@ -1347,25 +1347,25 @@ namespace Microsoft.OpenApi.Models.References public OpenApiSchemaReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument? hostDocument = null, string? externalResource = null) { } public Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema? AdditionalProperties { get; } public bool AdditionalPropertiesAllowed { get; } - public System.Collections.Generic.IList? AllOf { get; } - public System.Collections.Generic.IDictionary? Annotations { get; } - public System.Collections.Generic.IList? AnyOf { get; } + public System.Collections.Generic.List? AllOf { get; } + public System.Collections.Generic.Dictionary? Annotations { get; } + public System.Collections.Generic.List? AnyOf { get; } public string? Comment { get; } public string? Const { get; } public System.Text.Json.Nodes.JsonNode? Default { get; } - public System.Collections.Generic.IDictionary? Definitions { get; } - public System.Collections.Generic.IDictionary>? DependentRequired { get; } + public System.Collections.Generic.Dictionary? Definitions { get; } + public System.Collections.Generic.Dictionary>? DependentRequired { get; } public bool Deprecated { get; } public string? Description { get; set; } public Microsoft.OpenApi.Models.OpenApiDiscriminator? Discriminator { get; } public string? DynamicAnchor { get; } public string? DynamicRef { get; } - public System.Collections.Generic.IList? Enum { get; } + public System.Collections.Generic.List? Enum { get; } public System.Text.Json.Nodes.JsonNode? Example { get; } - public System.Collections.Generic.IList? Examples { get; } + public System.Collections.Generic.List? Examples { get; } public string? ExclusiveMaximum { get; } public string? ExclusiveMinimum { get; } - public System.Collections.Generic.IDictionary? Extensions { get; } + public System.Collections.Generic.Dictionary? Extensions { get; } public Microsoft.OpenApi.Models.OpenApiExternalDocs? ExternalDocs { get; } public string? Format { get; } public string? Id { get; } @@ -1380,19 +1380,19 @@ namespace Microsoft.OpenApi.Models.References public string? Minimum { get; } public decimal? MultipleOf { get; } public Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema? Not { get; } - public System.Collections.Generic.IList? OneOf { get; } + public System.Collections.Generic.List? OneOf { get; } public string? Pattern { get; } - public System.Collections.Generic.IDictionary? PatternProperties { get; } - public System.Collections.Generic.IDictionary? Properties { get; } + public System.Collections.Generic.Dictionary? PatternProperties { get; } + public System.Collections.Generic.Dictionary? Properties { get; } public bool ReadOnly { get; } - public System.Collections.Generic.ISet? Required { get; } + public System.Collections.Generic.HashSet? Required { get; } public System.Uri? Schema { get; } public string? Title { get; } public Microsoft.OpenApi.Models.JsonSchemaType? Type { get; } public bool UnevaluatedProperties { get; } public bool? UniqueItems { get; } - public System.Collections.Generic.IDictionary? UnrecognizedKeywords { get; } - public System.Collections.Generic.IDictionary? Vocabulary { get; } + public System.Collections.Generic.Dictionary? UnrecognizedKeywords { get; } + public System.Collections.Generic.Dictionary? Vocabulary { get; } public bool WriteOnly { get; } public Microsoft.OpenApi.Models.OpenApiXml? Xml { get; } public override Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema CopyReferenceAsTargetElementWithOverrides(Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema source) { } @@ -1406,7 +1406,7 @@ namespace Microsoft.OpenApi.Models.References public OpenApiSecuritySchemeReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument? hostDocument = null, string? externalResource = null) { } public string? BearerFormat { get; } public string? Description { get; set; } - public System.Collections.Generic.IDictionary? Extensions { get; } + public System.Collections.Generic.Dictionary? Extensions { get; } public Microsoft.OpenApi.Models.OpenApiOAuthFlows? Flows { get; } public Microsoft.OpenApi.Models.ParameterLocation? In { get; } public string? Name { get; } @@ -1420,7 +1420,7 @@ namespace Microsoft.OpenApi.Models.References { public OpenApiTagReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument? hostDocument = null, string? externalResource = null) { } public string? Description { get; } - public System.Collections.Generic.IDictionary? Extensions { get; } + public System.Collections.Generic.Dictionary? Extensions { get; } public Microsoft.OpenApi.Models.OpenApiExternalDocs? ExternalDocs { get; } public string? Name { get; } public override Microsoft.OpenApi.Models.Interfaces.IOpenApiTag? Target { get; } @@ -1433,9 +1433,9 @@ namespace Microsoft.OpenApi.Reader public class OpenApiDiagnostic : Microsoft.OpenApi.Interfaces.IDiagnostic { public OpenApiDiagnostic() { } - public System.Collections.Generic.IList Errors { get; set; } + public System.Collections.Generic.List Errors { get; set; } public Microsoft.OpenApi.OpenApiSpecVersion SpecificationVersion { get; set; } - public System.Collections.Generic.IList Warnings { get; set; } + public System.Collections.Generic.List Warnings { get; set; } public void AppendDiagnostic(Microsoft.OpenApi.Reader.OpenApiDiagnostic diagnosticToAdd, string? fileNameToAdd = null) { } } public class OpenApiJsonReader : Microsoft.OpenApi.Interfaces.IOpenApiReader @@ -1572,11 +1572,11 @@ namespace Microsoft.OpenApi.Services public class OpenApiUrlTreeNode { public static readonly System.Collections.Generic.IReadOnlyDictionary MermaidNodeStyles; - public System.Collections.Generic.IDictionary> AdditionalData { get; set; } - public System.Collections.Generic.IDictionary Children { get; } + public System.Collections.Generic.Dictionary> AdditionalData { get; set; } + public System.Collections.Generic.Dictionary Children { get; } public bool IsParameter { get; } public string Path { get; set; } - public System.Collections.Generic.IDictionary PathItems { get; } + public System.Collections.Generic.Dictionary PathItems { get; } public string Segment { get; } public void AddAdditionalData(System.Collections.Generic.Dictionary> additionalData) { } public void Attach(Microsoft.OpenApi.Models.OpenApiDocument doc, string label) { } @@ -1623,21 +1623,21 @@ namespace Microsoft.OpenApi.Services public virtual void Visit(Microsoft.OpenApi.Models.OpenApiServerVariable serverVariable) { } public virtual void Visit(Microsoft.OpenApi.Models.OpenApiTag tag) { } public virtual void Visit(Microsoft.OpenApi.Models.References.OpenApiTagReference tag) { } - public virtual void Visit(System.Collections.Generic.IDictionary operations) { } - public virtual void Visit(System.Collections.Generic.IDictionary callbacks) { } - public virtual void Visit(System.Collections.Generic.IDictionary examples) { } - public virtual void Visit(System.Collections.Generic.IDictionary headers) { } - public virtual void Visit(System.Collections.Generic.IDictionary links) { } - public virtual void Visit(System.Collections.Generic.IDictionary webhooks) { } - public virtual void Visit(System.Collections.Generic.IDictionary encodings) { } - public virtual void Visit(System.Collections.Generic.IDictionary content) { } - public virtual void Visit(System.Collections.Generic.IDictionary serverVariables) { } - public virtual void Visit(System.Collections.Generic.IList example) { } - public virtual void Visit(System.Collections.Generic.IList parameters) { } - public virtual void Visit(System.Collections.Generic.IList openApiSecurityRequirements) { } - public virtual void Visit(System.Collections.Generic.IList servers) { } - public virtual void Visit(System.Collections.Generic.ISet openApiTags) { } - public virtual void Visit(System.Collections.Generic.ISet openApiTags) { } + public virtual void Visit(System.Collections.Generic.Dictionary operations) { } + public virtual void Visit(System.Collections.Generic.Dictionary callbacks) { } + public virtual void Visit(System.Collections.Generic.Dictionary examples) { } + public virtual void Visit(System.Collections.Generic.Dictionary headers) { } + public virtual void Visit(System.Collections.Generic.Dictionary links) { } + public virtual void Visit(System.Collections.Generic.Dictionary webhooks) { } + public virtual void Visit(System.Collections.Generic.Dictionary encodings) { } + public virtual void Visit(System.Collections.Generic.Dictionary content) { } + public virtual void Visit(System.Collections.Generic.Dictionary serverVariables) { } + public virtual void Visit(System.Collections.Generic.HashSet openApiTags) { } + public virtual void Visit(System.Collections.Generic.HashSet openApiTags) { } + public virtual void Visit(System.Collections.Generic.List example) { } + public virtual void Visit(System.Collections.Generic.List parameters) { } + public virtual void Visit(System.Collections.Generic.List openApiSecurityRequirements) { } + public virtual void Visit(System.Collections.Generic.List servers) { } public virtual void Visit(System.Text.Json.Nodes.JsonNode node) { } } public class OpenApiWalker @@ -1662,16 +1662,16 @@ namespace Microsoft.OpenApi.Services public class OperationSearch : Microsoft.OpenApi.Services.OpenApiVisitorBase { public OperationSearch(System.Func predicate) { } - public System.Collections.Generic.IList SearchResults { get; } + public System.Collections.Generic.List SearchResults { get; } public override void Visit(Microsoft.OpenApi.Models.Interfaces.IOpenApiPathItem pathItem) { } - public override void Visit(System.Collections.Generic.IList parameters) { } + public override void Visit(System.Collections.Generic.List parameters) { } } public class SearchResult { public SearchResult() { } public Microsoft.OpenApi.Services.CurrentKeys? CurrentKeys { get; set; } public Microsoft.OpenApi.Models.OpenApiOperation? Operation { get; set; } - public System.Collections.Generic.IList? Parameters { get; set; } + public System.Collections.Generic.List? Parameters { get; set; } } } namespace Microsoft.OpenApi.Validations @@ -1719,15 +1719,15 @@ namespace Microsoft.OpenApi.Validations public override void Visit(Microsoft.OpenApi.Models.OpenApiServer server) { } public override void Visit(Microsoft.OpenApi.Models.OpenApiServerVariable serverVariable) { } public override void Visit(Microsoft.OpenApi.Models.OpenApiTag tag) { } - public override void Visit(System.Collections.Generic.IDictionary operations) { } - public override void Visit(System.Collections.Generic.IDictionary callbacks) { } - public override void Visit(System.Collections.Generic.IDictionary examples) { } - public override void Visit(System.Collections.Generic.IDictionary headers) { } - public override void Visit(System.Collections.Generic.IDictionary links) { } - public override void Visit(System.Collections.Generic.IDictionary encodings) { } - public override void Visit(System.Collections.Generic.IDictionary content) { } - public override void Visit(System.Collections.Generic.IDictionary serverVariables) { } - public override void Visit(System.Collections.Generic.IList example) { } + public override void Visit(System.Collections.Generic.Dictionary operations) { } + public override void Visit(System.Collections.Generic.Dictionary callbacks) { } + public override void Visit(System.Collections.Generic.Dictionary examples) { } + public override void Visit(System.Collections.Generic.Dictionary headers) { } + public override void Visit(System.Collections.Generic.Dictionary links) { } + public override void Visit(System.Collections.Generic.Dictionary encodings) { } + public override void Visit(System.Collections.Generic.Dictionary content) { } + public override void Visit(System.Collections.Generic.Dictionary serverVariables) { } + public override void Visit(System.Collections.Generic.List example) { } } public class OpenApiValidatorError : Microsoft.OpenApi.Models.OpenApiError { @@ -1752,23 +1752,23 @@ namespace Microsoft.OpenApi.Validations { public ValidationRuleSet() { } public ValidationRuleSet(Microsoft.OpenApi.Validations.ValidationRuleSet ruleSet) { } - public ValidationRuleSet(System.Collections.Generic.IDictionary> rules) { } + public ValidationRuleSet(System.Collections.Generic.Dictionary> rules) { } public int Count { get; } - public System.Collections.Generic.IList Rules { get; } + public System.Collections.Generic.List Rules { get; } public void Add(System.Type key, Microsoft.OpenApi.Validations.ValidationRule rule) { } - public void Add(System.Type key, System.Collections.Generic.IList rules) { } + public void Add(System.Type key, System.Collections.Generic.List rules) { } public void Clear() { } public bool Contains(System.Type key, Microsoft.OpenApi.Validations.ValidationRule rule) { } public bool ContainsKey(System.Type key) { } - public System.Collections.Generic.IList FindRules(System.Type type) { } + public System.Collections.Generic.List FindRules(System.Type type) { } public System.Collections.Generic.IEnumerator GetEnumerator() { } public bool Remove(Microsoft.OpenApi.Validations.ValidationRule rule) { } public bool Remove(System.Type key) { } public void Remove(string ruleName) { } public bool Remove(System.Type key, Microsoft.OpenApi.Validations.ValidationRule rule) { } - public bool TryGetValue(System.Type key, out System.Collections.Generic.IList? rules) { } + public bool TryGetValue(System.Type key, out System.Collections.Generic.List? rules) { } public bool Update(System.Type key, Microsoft.OpenApi.Validations.ValidationRule newRule, Microsoft.OpenApi.Validations.ValidationRule oldRule) { } - public static void AddValidationRules(Microsoft.OpenApi.Validations.ValidationRuleSet ruleSet, System.Collections.Generic.IDictionary> rules) { } + public static void AddValidationRules(Microsoft.OpenApi.Validations.ValidationRuleSet ruleSet, System.Collections.Generic.Dictionary> rules) { } public static Microsoft.OpenApi.Validations.ValidationRuleSet GetDefaultRuleSet() { } public static Microsoft.OpenApi.Validations.ValidationRuleSet GetEmptyRuleSet() { } } @@ -1859,7 +1859,7 @@ namespace Microsoft.OpenApi.Validations.Rules public static class OpenApiSchemaRules { public static Microsoft.OpenApi.Validations.ValidationRule ValidateSchemaDiscriminator { get; } - public static bool TraverseSchemaElements(string discriminatorName, System.Collections.Generic.IList? childSchema) { } + public static bool TraverseSchemaElements(string discriminatorName, System.Collections.Generic.List? childSchema) { } public static bool ValidateChildSchemaAgainstDiscriminator(Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema schema, string? discriminatorName) { } } [Microsoft.OpenApi.Validations.Rules.OpenApiRule] @@ -1921,7 +1921,7 @@ namespace Microsoft.OpenApi.Writers public static class OpenApiWriterAnyExtensions { public static void WriteAny(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, System.Text.Json.Nodes.JsonNode? node) { } - public static void WriteExtensions(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, System.Collections.Generic.IDictionary? extensions, Microsoft.OpenApi.OpenApiSpecVersion specVersion) { } + public static void WriteExtensions(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, System.Collections.Generic.Dictionary? extensions, Microsoft.OpenApi.OpenApiSpecVersion specVersion) { } } public abstract class OpenApiWriterBase : Microsoft.OpenApi.Writers.IOpenApiWriter { @@ -1968,13 +1968,13 @@ namespace Microsoft.OpenApi.Writers { public static void WriteOptionalCollection(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.IEnumerable? elements, System.Action action) { } public static void WriteOptionalCollection(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.IEnumerable? elements, System.Action action) { } - public static void WriteOptionalMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.IDictionary>? elements, System.Action> action) { } - public static void WriteOptionalMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.IDictionary? elements, System.Action action) { } - public static void WriteOptionalMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.IDictionary? elements, System.Action action) { } - public static void WriteOptionalMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.IDictionary? elements, System.Action action) { } - public static void WriteOptionalMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.IDictionary? elements, System.Action action) + public static void WriteOptionalMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.Dictionary>? elements, System.Action> action) { } + public static void WriteOptionalMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.Dictionary? elements, System.Action action) { } + public static void WriteOptionalMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.Dictionary? elements, System.Action action) { } + public static void WriteOptionalMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.Dictionary? elements, System.Action action) { } + public static void WriteOptionalMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.Dictionary? elements, System.Action action) where T : Microsoft.OpenApi.Interfaces.IOpenApiElement { } - public static void WriteOptionalMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.IDictionary? elements, System.Action action) + public static void WriteOptionalMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.Dictionary? elements, System.Action action) where T : Microsoft.OpenApi.Interfaces.IOpenApiElement { } public static void WriteOptionalObject(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, T? value, System.Action action) { } public static void WriteProperty(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, string? value) { } @@ -1986,8 +1986,8 @@ namespace Microsoft.OpenApi.Writers where T : struct { } public static void WriteRequiredCollection(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.IEnumerable elements, System.Action action) where T : Microsoft.OpenApi.Interfaces.IOpenApiElement { } - public static void WriteRequiredMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.IDictionary? elements, System.Action action) { } - public static void WriteRequiredMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.IDictionary? elements, System.Action action) + public static void WriteRequiredMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.Dictionary? elements, System.Action action) { } + public static void WriteRequiredMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.Dictionary? elements, System.Action action) where T : Microsoft.OpenApi.Interfaces.IOpenApiElement { } public static void WriteRequiredObject(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, T? value, System.Action action) { } public static void WriteRequiredProperty(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, string? value) { } diff --git a/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.cs b/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.cs index 3292a6990..702b4ed12 100644 --- a/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.cs +++ b/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.cs @@ -21,14 +21,14 @@ public class OpenApiUrlTreeNodeTests { ["/"] = new OpenApiPathItem() { - Operations = new Dictionary + Operations = new() { [HttpMethod.Get] = new(), } }, ["/houses"] = new OpenApiPathItem() { - Operations = new Dictionary + Operations = new() { [HttpMethod.Get] = new(), [HttpMethod.Post] = new() @@ -36,7 +36,7 @@ public class OpenApiUrlTreeNodeTests }, ["/cars"] = new OpenApiPathItem() { - Operations = new Dictionary + Operations = new() { [HttpMethod.Post] = new() } @@ -149,7 +149,7 @@ public void AttachPathWorks() var pathItem1 = new OpenApiPathItem { - Operations = new Dictionary + Operations = new() { { HttpMethod.Get, new OpenApiOperation @@ -174,7 +174,7 @@ public void AttachPathWorks() var pathItem2 = new OpenApiPathItem { - Operations = new Dictionary + Operations = new() { { HttpMethod.Get, new OpenApiOperation @@ -241,7 +241,7 @@ public void HasOperationsWorks() ["/houses"] = new OpenApiPathItem(), ["/cars/{car-id}"] = new OpenApiPathItem() { - Operations = new Dictionary + Operations = new() { { HttpMethod.Get, new OpenApiOperation @@ -269,7 +269,7 @@ public void HasOperationsWorks() { ["/cars/{car-id}"] = new OpenApiPathItem() { - Operations = new Dictionary + Operations = new() { { HttpMethod.Get, new OpenApiOperation diff --git a/test/Microsoft.OpenApi.Tests/Services/OpenApiValidatorTests.cs b/test/Microsoft.OpenApi.Tests/Services/OpenApiValidatorTests.cs index 90f88e378..1de888cd3 100644 --- a/test/Microsoft.OpenApi.Tests/Services/OpenApiValidatorTests.cs +++ b/test/Microsoft.OpenApi.Tests/Services/OpenApiValidatorTests.cs @@ -37,17 +37,17 @@ public void ResponseMustHaveADescription() "/test", new OpenApiPathItem() { - Operations = - { - [HttpMethod.Get] = new() + Operations = new Dictionary { - Responses = + [HttpMethod.Get] = new() { - ["200"] = new OpenApiResponse() + Responses = + { + ["200"] = new OpenApiResponse() + } } } } - } } } }; @@ -74,7 +74,7 @@ public void ServersShouldBeReferencedByIndex() Title = "foo", Version = "1.2.2" }, - Servers = new List { + Servers = [ new() { Url = "http://example.org" @@ -82,7 +82,7 @@ public void ServersShouldBeReferencedByIndex() new() { }, - }, + ], Paths = new() }; @@ -131,7 +131,10 @@ public void ValidateCustomExtension() var extensionNode = JsonSerializer.Serialize(fooExtension); var jsonNode = JsonNode.Parse(extensionNode); - openApiDocument.Info.Extensions.Add("x-foo", new OpenApiAny(jsonNode)); + openApiDocument.Info.Extensions = new Dictionary + { + { "x-foo", new OpenApiAny(jsonNode) } + }; var validator = new OpenApiValidator(ruleset); var walker = new OpenApiWalker(validator); diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiHeaderValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiHeaderValidationTests.cs index 6c96c3d97..b70eea7bc 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiHeaderValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiHeaderValidationTests.cs @@ -57,7 +57,7 @@ public void ValidateExamplesShouldNotHaveDataTypeMismatchForSimpleSchema() Type = JsonSchemaType.Integer } }, - Examples = + Examples = new Dictionary { ["example0"] = new OpenApiExample() { diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiMediaTypeValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiMediaTypeValidationTests.cs index 05b4bb62c..17d3bdd54 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiMediaTypeValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiMediaTypeValidationTests.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Text.Json.Nodes; using Microsoft.OpenApi.Models; +using Microsoft.OpenApi.Models.Interfaces; using Microsoft.OpenApi.Services; using Xunit; @@ -55,8 +56,8 @@ public void ValidateExamplesShouldNotHaveDataTypeMismatchForSimpleSchema() Type = JsonSchemaType.Integer, } }, - Examples = - { + Examples = new Dictionary + { ["example0"] = new OpenApiExample() { Value = "1", diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiOAuthFlowValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiOAuthFlowValidationTests.cs index ad8e5f387..0c7778215 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiOAuthFlowValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiOAuthFlowValidationTests.cs @@ -19,6 +19,8 @@ public void ValidateFixedFieldsIsRequiredInResponse() // Arrange var authorizationUrlError = string.Format(SRResource.Validation_FieldIsRequired, "authorizationUrl", "OAuth Flow"); var tokenUrlError = string.Format(SRResource.Validation_FieldIsRequired, "tokenUrl", "OAuth Flow"); + var scopesError = string.Format(SRResource.Validation_FieldIsRequired, "scopes", "OAuth Flow"); + IEnumerable errors; var oAuthFlow = new OpenApiOAuthFlow(); @@ -33,8 +35,8 @@ public void ValidateFixedFieldsIsRequiredInResponse() // Assert Assert.False(result); Assert.NotNull(errors); - Assert.Equal(2, errors.Count()); - Assert.Equal(new[] { authorizationUrlError, tokenUrlError }, errors.Select(e => e.Message)); + Assert.Equal(3, errors.Count()); + Assert.Equal(new[] { authorizationUrlError, tokenUrlError, scopesError }, errors.Select(e => e.Message)); } } } diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiParameterValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiParameterValidationTests.cs index 721445e23..6142bd082 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiParameterValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiParameterValidationTests.cs @@ -107,8 +107,8 @@ public void ValidateExamplesShouldNotHaveDataTypeMismatchForSimpleSchema() Type = JsonSchemaType.Integer, } }, - Examples = - { + Examples = new Dictionary + { ["example0"] = new OpenApiExample() { Value = "1", diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiReferenceValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiReferenceValidationTests.cs index 1828ca470..0fb23578b 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiReferenceValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiReferenceValidationTests.cs @@ -29,7 +29,7 @@ public void ReferencedSchemaShouldOnlyBeValidatedOnce() var document = new OpenApiDocument(); document.Components = new() { - Schemas = new Dictionary() + Schemas = new() { ["test"] = sharedSchema } @@ -39,7 +39,7 @@ public void ReferencedSchemaShouldOnlyBeValidatedOnce() { ["/"] = new OpenApiPathItem() { - Operations = new Dictionary + Operations = new() { [HttpMethod.Get] = new() { @@ -47,7 +47,7 @@ public void ReferencedSchemaShouldOnlyBeValidatedOnce() { ["200"] = new OpenApiResponse() { - Content = new Dictionary + Content = new() { ["application/json"] = new() { @@ -62,7 +62,7 @@ public void ReferencedSchemaShouldOnlyBeValidatedOnce() }; // Act - var rules = new Dictionary>() + var rules = new Dictionary>() { { typeof(IOpenApiSchema), new List() { new AlwaysFailRule() } @@ -93,7 +93,7 @@ public void UnresolvedSchemaReferencedShouldNotBeValidated() { ["/"] = new OpenApiPathItem() { - Operations = new Dictionary + Operations = new() { [HttpMethod.Get] = new() { @@ -101,7 +101,7 @@ public void UnresolvedSchemaReferencedShouldNotBeValidated() { ["200"] = new OpenApiResponse() { - Content = new Dictionary + Content = new() { ["application/json"] = new() { @@ -116,7 +116,7 @@ public void UnresolvedSchemaReferencedShouldNotBeValidated() }; // Act - var rules = new Dictionary>() + var rules = new Dictionary>() { { typeof(OpenApiSchema), new List() { new AlwaysFailRule() } diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiSchemaValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiSchemaValidationTests.cs index d8820defc..f0c772473 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiSchemaValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiSchemaValidationTests.cs @@ -73,8 +73,8 @@ public void ValidateEnumShouldNotHaveDataTypeMismatchForSimpleSchema() IEnumerable warnings; var schema = new OpenApiSchema() { - Enum = - { + Enum = + [ new OpenApiAny("1").Node, new OpenApiAny(new JsonObject() { @@ -88,7 +88,7 @@ public void ValidateEnumShouldNotHaveDataTypeMismatchForSimpleSchema() ["x"] = 4, ["y"] = 40, }).Node - }, + ], Type = JsonSchemaType.Object, AdditionalProperties = new OpenApiSchema() { @@ -115,7 +115,7 @@ public void ValidateDefaultShouldNotHaveDataTypeMismatchForComplexSchema() var schema = new OpenApiSchema { Type = JsonSchemaType.Object, - Properties = + Properties = new Dictionary { ["property1"] = new OpenApiSchema() { @@ -187,7 +187,8 @@ public void ValidateSchemaRequiredFieldListMustContainThePropertySpecifiedInTheD { var components = new OpenApiComponents { - Schemas = { + Schemas = new Dictionary + { { "schema1", new OpenApiSchema @@ -219,7 +220,7 @@ public void ValidateOneOfSchemaPropertyNameContainsPropertySpecifiedInTheDiscrim // Arrange var components = new OpenApiComponents { - Schemas = + Schemas = new Dictionary { { "Person", @@ -230,11 +231,11 @@ public void ValidateOneOfSchemaPropertyNameContainsPropertySpecifiedInTheDiscrim { PropertyName = "type" }, - OneOf = new List - { + OneOf = + [ new OpenApiSchema() { - Properties = + Properties = new Dictionary { { "type", @@ -245,7 +246,7 @@ public void ValidateOneOfSchemaPropertyNameContainsPropertySpecifiedInTheDiscrim } }, } - }, + ], } } } diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiTagValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiTagValidationTests.cs index d956e2cd0..9824b17f6 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiTagValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiTagValidationTests.cs @@ -42,7 +42,10 @@ public void ValidateExtensionNameStartsWithXDashInTag() { Name = "tag" }; - tag.Extensions.Add("tagExt", new OpenApiAny("value")); + tag.Extensions = new Dictionary + { + { "tagExt", new OpenApiAny("value") } + }; // Act var validator = new OpenApiValidator(ValidationRuleSet.GetDefaultRuleSet()); diff --git a/test/Microsoft.OpenApi.Tests/Validations/ValidationRuleSetTests.cs b/test/Microsoft.OpenApi.Tests/Validations/ValidationRuleSetTests.cs index 6b4a920cf..48ac1f105 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/ValidationRuleSetTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/ValidationRuleSetTests.cs @@ -22,15 +22,15 @@ public class ValidationRuleSetTests private readonly ValidationRule _parameterValidationRule = new ValidationRule(nameof(_parameterValidationRule), (context, item) => { }); - private readonly IDictionary> _rulesDictionary; + private readonly Dictionary> _rulesDictionary; public ValidationRuleSetTests() { - _rulesDictionary = new Dictionary>() + _rulesDictionary = new Dictionary>() { - {typeof(OpenApiContact), new List { _contactValidationRule } }, - {typeof(OpenApiHeader), new List { _headerValidationRule } }, - {typeof(OpenApiParameter), new List { _parameterValidationRule } } + {typeof(OpenApiContact), [_contactValidationRule] }, + {typeof(OpenApiHeader), [_headerValidationRule] }, + {typeof(OpenApiParameter), [_parameterValidationRule] } }; } @@ -69,7 +69,7 @@ public void RemoveValidatioRuleGivenTheValidationRuleWorks() // Act and Assert Assert.True(ruleSet.Remove(_contactValidationRule)); - Assert.False(ruleSet.Rules.Contains(_contactValidationRule)); + Assert.DoesNotContain(_contactValidationRule, ruleSet.Rules); Assert.False(ruleSet.Remove(_contactValidationRule)); // rule already removed } @@ -87,9 +87,9 @@ public void RemoveValidationRuleGivenTheKeyAndValidationRuleWorks() var rules = ruleSet.Rules; // Assert - Assert.False(rules.Contains(_contactValidationRule)); - Assert.True(rules.Contains(_headerValidationRule)); - Assert.True(rules.Contains(_parameterValidationRule)); + Assert.DoesNotContain(_contactValidationRule, rules); + Assert.Contains(_headerValidationRule, rules); + Assert.Contains(_parameterValidationRule, rules); } [Fact] @@ -98,9 +98,9 @@ public void RemoveRulesGivenAKeyWorks() // Arrange var ruleSet = new ValidationRuleSet(_rulesDictionary); var responseValidationRule = new ValidationRule("ValidateResponses", (context, item) => { }); - ruleSet.Add(typeof(OpenApiResponse), new List { responseValidationRule }); + ruleSet.Add(typeof(OpenApiResponse), [responseValidationRule]); Assert.True(ruleSet.ContainsKey(typeof(OpenApiResponse))); - Assert.True(ruleSet.Rules.Contains(responseValidationRule)); // guard + Assert.Contains(responseValidationRule, ruleSet.Rules); // guard // Act ruleSet.Remove(typeof(OpenApiResponse)); @@ -119,11 +119,11 @@ public void AddNewValidationRuleWorks() var pathsValidationRule = new ValidationRule("ValidatePaths", (context, item) => { }); // Act - ruleSet.Add(typeof(OpenApiResponse), new List { responseValidationRule }); - ruleSet.Add(typeof(OpenApiTag), new List { tagValidationRule }); - var rulesDictionary = new Dictionary>() + ruleSet.Add(typeof(OpenApiResponse), [responseValidationRule]); + ruleSet.Add(typeof(OpenApiTag), [tagValidationRule]); + var rulesDictionary = new Dictionary>() { - {typeof(OpenApiPaths), new List { pathsValidationRule } } + {typeof(OpenApiPaths), [pathsValidationRule] } }; ValidationRuleSet.AddValidationRules(ruleSet, rulesDictionary); @@ -132,9 +132,9 @@ public void AddNewValidationRuleWorks() Assert.True(ruleSet.ContainsKey(typeof(OpenApiResponse))); Assert.True(ruleSet.ContainsKey(typeof(OpenApiTag))); Assert.True(ruleSet.ContainsKey(typeof(OpenApiPaths))); - Assert.True(ruleSet.Rules.Contains(responseValidationRule)); - Assert.True(ruleSet.Rules.Contains(tagValidationRule)); - Assert.True(ruleSet.Rules.Contains(pathsValidationRule)); + Assert.Contains(responseValidationRule, ruleSet.Rules); + Assert.Contains(tagValidationRule, ruleSet.Rules); + Assert.Contains(pathsValidationRule, ruleSet.Rules); } [Fact] @@ -143,7 +143,7 @@ public void UpdateValidationRuleWorks() // Arrange var ruleSet = new ValidationRuleSet(_rulesDictionary); var responseValidationRule = new ValidationRule("ValidateResponses", (context, item) => { }); - ruleSet.Add(typeof(OpenApiResponse), new List { responseValidationRule }); + ruleSet.Add(typeof(OpenApiResponse), [responseValidationRule]); // Act var pathsValidationRule = new ValidationRule("ValidatePaths", (context, item) => { }); @@ -165,7 +165,7 @@ public void TryGetValueWorks() // Assert Assert.True(validationRules.Any()); - Assert.True(validationRules.Contains(_contactValidationRule)); + Assert.Contains(_contactValidationRule, validationRules); } [Fact] @@ -175,10 +175,10 @@ public void ClearAllRulesWorks() var ruleSet = new ValidationRuleSet(); var tagValidationRule = new ValidationRule("ValidateTags", (context, item) => { }); var pathsValidationRule = new ValidationRule("ValidatePaths", (context, item) => { }); - var rulesDictionary = new Dictionary>() + var rulesDictionary = new Dictionary>() { - {typeof(OpenApiPaths), new List { pathsValidationRule } }, - {typeof(OpenApiTag), new List { tagValidationRule } } + {typeof(OpenApiPaths), [pathsValidationRule] }, + {typeof(OpenApiTag), [tagValidationRule] } }; ValidationRuleSet.AddValidationRules(ruleSet, rulesDictionary); diff --git a/test/Microsoft.OpenApi.Tests/Visitors/InheritanceTests.cs b/test/Microsoft.OpenApi.Tests/Visitors/InheritanceTests.cs index ee7252d42..030e60581 100644 --- a/test/Microsoft.OpenApi.Tests/Visitors/InheritanceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Visitors/InheritanceTests.cs @@ -24,28 +24,28 @@ public void ExpectedVirtualsInvolved() visitor.Visit(default(OpenApiInfo)); visitor.Visit(default(OpenApiContact)); visitor.Visit(default(OpenApiLicense)); - visitor.Visit(default(IList)); + visitor.Visit(default(List)); visitor.Visit(default(OpenApiServer)); visitor.Visit(default(OpenApiPaths)); visitor.Visit(default(IOpenApiPathItem)); visitor.Visit(default(OpenApiServerVariable)); - visitor.Visit(default(IDictionary)); + visitor.Visit(default(Dictionary)); visitor.Visit(default(OpenApiOperation)); - visitor.Visit(default(IList)); + visitor.Visit(default(List)); visitor.Visit(default(IOpenApiParameter)); visitor.Visit(default(IOpenApiRequestBody)); - visitor.Visit(default(IDictionary)); - visitor.Visit(default(IDictionary)); + visitor.Visit(default(Dictionary)); + visitor.Visit(default(Dictionary)); visitor.Visit(default(IOpenApiResponse)); visitor.Visit(default(OpenApiResponses)); - visitor.Visit(default(IDictionary)); + visitor.Visit(default(Dictionary)); visitor.Visit(default(OpenApiMediaType)); visitor.Visit(default(OpenApiEncoding)); - visitor.Visit(default(IDictionary)); + visitor.Visit(default(Dictionary)); visitor.Visit(default(OpenApiComponents)); visitor.Visit(default(OpenApiExternalDocs)); visitor.Visit(default(IOpenApiSchema)); - visitor.Visit(default(IDictionary)); + visitor.Visit(default(Dictionary)); visitor.Visit(default(IOpenApiLink)); visitor.Visit(default(IOpenApiCallback)); visitor.Visit(default(OpenApiTag)); @@ -54,13 +54,13 @@ public void ExpectedVirtualsInvolved() visitor.Visit(default(OpenApiSecurityRequirement)); visitor.Visit(default(IOpenApiSecurityScheme)); visitor.Visit(default(IOpenApiExample)); - visitor.Visit(default(ISet)); - visitor.Visit(default(IList)); + visitor.Visit(default(HashSet)); + visitor.Visit(default(List)); visitor.Visit(default(IOpenApiExtensible)); visitor.Visit(default(IOpenApiExtension)); - visitor.Visit(default(IList)); - visitor.Visit(default(IDictionary)); - visitor.Visit(default(IDictionary)); + visitor.Visit(default(List)); + visitor.Visit(default(Dictionary)); + visitor.Visit(default(Dictionary)); visitor.Visit(default(IOpenApiReferenceHolder)); visitor.Exit(); Assert.True(42 < ((TestVisitor)visitor).CallStack.Count); @@ -113,7 +113,7 @@ public override void Visit(OpenApiLicense license) base.Visit(license); } - public override void Visit(IList servers) + public override void Visit(List servers) { EncodeCall(); base.Visit(servers); @@ -143,7 +143,7 @@ public override void Visit(OpenApiServerVariable serverVariable) base.Visit(serverVariable); } - public override void Visit(IDictionary operations) + public override void Visit(Dictionary operations) { EncodeCall(); base.Visit(operations); @@ -155,7 +155,7 @@ public override void Visit(OpenApiOperation operation) base.Visit(operation); } - public override void Visit(IList parameters) + public override void Visit(List parameters) { EncodeCall(); base.Visit(parameters); @@ -173,13 +173,13 @@ public override void Visit(IOpenApiRequestBody requestBody) base.Visit(requestBody); } - public override void Visit(IDictionary headers) + public override void Visit(Dictionary headers) { EncodeCall(); base.Visit(headers); } - public override void Visit(IDictionary callbacks) + public override void Visit(Dictionary callbacks) { EncodeCall(); base.Visit(callbacks); @@ -197,7 +197,7 @@ public override void Visit(OpenApiResponses response) base.Visit(response); } - public override void Visit(IDictionary content) + public override void Visit(Dictionary content) { EncodeCall(); base.Visit(content); @@ -215,7 +215,7 @@ public override void Visit(OpenApiEncoding encoding) base.Visit(encoding); } - public override void Visit(IDictionary examples) + public override void Visit(Dictionary examples) { EncodeCall(); base.Visit(examples); @@ -239,7 +239,7 @@ public override void Visit(IOpenApiSchema schema) base.Visit(schema); } - public override void Visit(IDictionary links) + public override void Visit(Dictionary links) { EncodeCall(); base.Visit(links); @@ -293,13 +293,13 @@ public override void Visit(IOpenApiExample example) base.Visit(example); } - public override void Visit(ISet openApiTags) + public override void Visit(HashSet openApiTags) { EncodeCall(); base.Visit(openApiTags); } - public override void Visit(IList openApiSecurityRequirements) + public override void Visit(List openApiSecurityRequirements) { EncodeCall(); base.Visit(openApiSecurityRequirements); @@ -317,19 +317,19 @@ public override void Visit(IOpenApiExtension openApiExtension) base.Visit(openApiExtension); } - public override void Visit(IList example) + public override void Visit(List example) { EncodeCall(); base.Visit(example); } - public override void Visit(IDictionary serverVariables) + public override void Visit(Dictionary serverVariables) { EncodeCall(); base.Visit(serverVariables); } - public override void Visit(IDictionary encodings) + public override void Visit(Dictionary encodings) { EncodeCall(); base.Visit(encodings); diff --git a/test/Microsoft.OpenApi.Tests/Walkers/WalkerLocationTests.cs b/test/Microsoft.OpenApi.Tests/Walkers/WalkerLocationTests.cs index 6af474e22..01f3c223b 100644 --- a/test/Microsoft.OpenApi.Tests/Walkers/WalkerLocationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Walkers/WalkerLocationTests.cs @@ -37,11 +37,11 @@ public void LocateTopLevelArrayItems() { var doc = new OpenApiDocument { - Servers = new List - { + Servers = + [ new(), new() - }, + ], Tags = new HashSet { new() @@ -68,7 +68,7 @@ public void LocatePathOperationContentSchema() var doc = new OpenApiDocument(); doc.Paths.Add("/test", new OpenApiPathItem() { - Operations = new Dictionary + Operations = new() { [HttpMethod.Get] = new() { @@ -76,7 +76,7 @@ public void LocatePathOperationContentSchema() { ["200"] = new OpenApiResponse() { - Content = new Dictionary + Content = new() { ["application/json"] = new() { @@ -119,7 +119,7 @@ public void WalkDOMWithCycles() var loopySchema = new OpenApiSchema { Type = JsonSchemaType.Object, - Properties = new Dictionary + Properties = new() { ["name"] = new OpenApiSchema() { Type = JsonSchemaType.String } } @@ -131,7 +131,7 @@ public void WalkDOMWithCycles() { Components = new() { - Schemas = new Dictionary + Schemas = new() { ["loopy"] = loopySchema } @@ -162,7 +162,7 @@ public void LocateReferences() var derivedSchema = new OpenApiSchema { - AnyOf = new List { new OpenApiSchemaReference("base") }, + AnyOf = [new OpenApiSchemaReference("base")], }; var testHeader = new OpenApiHeader() @@ -177,7 +177,7 @@ public void LocateReferences() { ["/"] = new OpenApiPathItem() { - Operations = new Dictionary + Operations = new() { [HttpMethod.Get] = new() { @@ -185,14 +185,14 @@ public void LocateReferences() { ["200"] = new OpenApiResponse() { - Content = new Dictionary + Content = new() { ["application/json"] = new() { Schema = new OpenApiSchemaReference("derived") } }, - Headers = + Headers = new Dictionary { ["test-header"] = testHeaderReference } @@ -204,12 +204,12 @@ public void LocateReferences() }, Components = new() { - Schemas = new Dictionary + Schemas = new() { ["derived"] = derivedSchema, ["base"] = baseSchema, }, - Headers = + Headers = new Dictionary { ["test-header"] = testHeader }, @@ -285,7 +285,7 @@ public override void Visit(IOpenApiReferenceHolder referenceable) { Locations.Add("referenceAt: " + this.PathString); } - public override void Visit(IDictionary content) + public override void Visit(Dictionary content) { Locations.Add(this.PathString); } @@ -301,12 +301,12 @@ public override void Visit(IOpenApiSchema schema) Locations.Add(this.PathString); } - public override void Visit(ISet openApiTags) + public override void Visit(HashSet openApiTags) { Locations.Add(this.PathString); } - public override void Visit(IList servers) + public override void Visit(List servers) { Locations.Add(this.PathString); } @@ -315,7 +315,7 @@ public override void Visit(OpenApiServer server) { Locations.Add(this.PathString); } - public override void Visit(ISet openApiTags) + public override void Visit(HashSet openApiTags) { Locations.Add(this.PathString); } diff --git a/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiReferencableTests.cs b/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiReferencableTests.cs index 167d5e359..17dab923b 100644 --- a/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiReferencableTests.cs +++ b/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiReferencableTests.cs @@ -7,6 +7,7 @@ using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; +using Microsoft.OpenApi.Models.Interfaces; using Microsoft.OpenApi.Properties; using Xunit; @@ -20,7 +21,7 @@ public class OpenApiReferencableTests private static readonly OpenApiHeader _headerFragment = new() { Schema = new OpenApiSchema(), - Examples = + Examples = new Dictionary { { "example1", new OpenApiExample() } } @@ -28,7 +29,7 @@ public class OpenApiReferencableTests private static readonly OpenApiParameter _parameterFragment = new() { Schema = new OpenApiSchema(), - Examples = + Examples = new Dictionary { { "example1", new OpenApiExample() } } @@ -36,32 +37,31 @@ public class OpenApiReferencableTests private static readonly OpenApiRequestBody _requestBodyFragment = new(); private static readonly OpenApiResponse _responseFragment = new() { - Headers = + Headers = new Dictionary { { "header1", new OpenApiHeader() } }, - Links = + Links = new Dictionary { { "link1", new OpenApiLink() } } }; private static readonly OpenApiSecurityScheme _securitySchemeFragment = new OpenApiSecurityScheme(); public static IEnumerable ResolveReferenceCanResolveValidJsonPointersTestData => - new List - { - new object[] { _callbackFragment, "/", _callbackFragment }, - new object[] { _exampleFragment, "/", _exampleFragment }, - new object[] { _linkFragment, "/", _linkFragment }, - new object[] { _headerFragment, "/", _headerFragment }, - new object[] { _headerFragment, "/examples/example1", _headerFragment.Examples["example1"] }, - new object[] { _parameterFragment, "/", _parameterFragment }, - new object[] { _parameterFragment, "/examples/example1", _parameterFragment.Examples["example1"] }, - new object[] { _requestBodyFragment, "/", _requestBodyFragment }, - new object[] { _responseFragment, "/", _responseFragment }, - new object[] { _responseFragment, "/headers/header1", _responseFragment.Headers["header1"] }, - new object[] { _responseFragment, "/links/link1", _responseFragment.Links["link1"] }, - new object[] { _securitySchemeFragment, "/", _securitySchemeFragment}, - }; + [ + [_callbackFragment, "/", _callbackFragment], + [_exampleFragment, "/", _exampleFragment], + [_linkFragment, "/", _linkFragment], + [_headerFragment, "/", _headerFragment], + [_headerFragment, "/examples/example1", _headerFragment.Examples["example1"]], + [_parameterFragment, "/", _parameterFragment], + [_parameterFragment, "/examples/example1", _parameterFragment.Examples["example1"]], + [_requestBodyFragment, "/", _requestBodyFragment], + [_responseFragment, "/", _responseFragment], + [_responseFragment, "/headers/header1", _responseFragment.Headers["header1"]], + [_responseFragment, "/links/link1", _responseFragment.Links["link1"]], + [_securitySchemeFragment, "/", _securitySchemeFragment], + ]; [Theory] [MemberData(nameof(ResolveReferenceCanResolveValidJsonPointersTestData))] @@ -78,25 +78,24 @@ public void ResolveReferenceCanResolveValidJsonPointers( } public static IEnumerable ResolveReferenceShouldThrowOnInvalidReferenceIdTestData => - new List - { - new object[] { _callbackFragment, "/a" }, - new object[] { _headerFragment, "/a" }, - new object[] { _headerFragment, "/examples" }, - new object[] { _headerFragment, "/examples/" }, - new object[] { _headerFragment, "/examples/a" }, - new object[] { _parameterFragment, "/a" }, - new object[] { _parameterFragment, "/examples" }, - new object[] { _parameterFragment, "/examples/" }, - new object[] { _parameterFragment, "/examples/a" }, - new object[] { _responseFragment, "/a" }, - new object[] { _responseFragment, "/headers" }, - new object[] { _responseFragment, "/headers/" }, - new object[] { _responseFragment, "/headers/a" }, - new object[] { _responseFragment, "/content" }, - new object[] { _responseFragment, "/content/" }, - new object[] { _responseFragment, "/content/a" } - }; + [ + [_callbackFragment, "/a"], + [_headerFragment, "/a"], + [_headerFragment, "/examples"], + [_headerFragment, "/examples/"], + [_headerFragment, "/examples/a"], + [_parameterFragment, "/a"], + [_parameterFragment, "/examples"], + [_parameterFragment, "/examples/"], + [_parameterFragment, "/examples/a"], + [_responseFragment, "/a"], + [_responseFragment, "/headers"], + [_responseFragment, "/headers/"], + [_responseFragment, "/headers/a"], + [_responseFragment, "/content"], + [_responseFragment, "/content/"], + [_responseFragment, "/content/a"] + ]; [Theory] [MemberData(nameof(ResolveReferenceShouldThrowOnInvalidReferenceIdTestData))] diff --git a/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiWorkspaceTests.cs b/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiWorkspaceTests.cs index 02c1cf07c..ba66aeedf 100644 --- a/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiWorkspaceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiWorkspaceTests.cs @@ -6,6 +6,7 @@ using System.Net.Http; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; +using Microsoft.OpenApi.Models.Interfaces; using Microsoft.OpenApi.Models.References; using Microsoft.OpenApi.Services; using Xunit; @@ -28,7 +29,7 @@ public void OpenApiWorkspacesCanAddComponentsFromAnotherDocument() { ["/"] = new OpenApiPathItem() { - Operations = new Dictionary() + Operations = new() { [HttpMethod.Get] = new OpenApiOperation() { @@ -36,7 +37,7 @@ public void OpenApiWorkspacesCanAddComponentsFromAnotherDocument() { ["200"] = new OpenApiResponse() { - Content = new Dictionary() + Content = new() { ["application/json"] = new OpenApiMediaType() { @@ -55,7 +56,8 @@ public void OpenApiWorkspacesCanAddComponentsFromAnotherDocument() { Components = new OpenApiComponents() { - Schemas = { + Schemas = new() + { ["test"] = testSchema } } @@ -108,7 +110,7 @@ public void OpenApiWorkspacesCanResolveReferencesToDocumentFragmentsWithJsonPoin var workspace = new OpenApiWorkspace(); var responseFragment = new OpenApiResponse { - Headers = + Headers = new Dictionary { { "header1", new OpenApiHeader() } } @@ -130,7 +132,7 @@ private static OpenApiDocument CreateCommonDocument() { Components = new() { - Schemas = + Schemas = new() { ["test"] = new OpenApiSchema() { diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiJsonWriterTests.cs b/test/Microsoft.OpenApi.Tests/Writers/OpenApiJsonWriterTests.cs index 54fb8cfb6..fb149b5ec 100644 --- a/test/Microsoft.OpenApi.Tests/Writers/OpenApiJsonWriterTests.cs +++ b/test/Microsoft.OpenApi.Tests/Writers/OpenApiJsonWriterTests.cs @@ -75,10 +75,9 @@ public async Task WriteStringListAsJsonShouldMatchExpected(string[] stringValues public static IEnumerable WriteMapAsJsonShouldMatchExpectedTestCasesSimple() { return - from input in new IDictionary[] { + from input in new Dictionary[] { // Simple map - new Dictionary - { + new() { ["property1"] = "value1", ["property2"] = "value2", ["property3"] = "value3", @@ -86,8 +85,7 @@ public static IEnumerable WriteMapAsJsonShouldMatchExpectedTestCasesSi }, // Simple map with duplicate values - new Dictionary - { + new() { ["property1"] = "value1", ["property2"] = "value1", ["property3"] = "value1", @@ -101,10 +99,9 @@ from shouldBeTerse in shouldProduceTerseOutputValues public static IEnumerable WriteMapAsJsonShouldMatchExpectedTestCasesComplex() { return - from input in new IDictionary[] { + from input in new Dictionary[] { // Empty map and empty list - new Dictionary - { + new() { ["property1"] = new Dictionary(), ["property2"] = new List(), ["property3"] = new List @@ -115,8 +112,7 @@ public static IEnumerable WriteMapAsJsonShouldMatchExpectedTestCasesCo }, // Number, boolean, and null handling - new Dictionary - { + new() { ["property1"] = "10.0", ["property2"] = "10", ["property3"] = "-5", @@ -131,16 +127,14 @@ public static IEnumerable WriteMapAsJsonShouldMatchExpectedTestCasesCo }, // DateTime - new Dictionary - { + new() { ["property1"] = new DateTime(1970, 01, 01), ["property2"] = new DateTimeOffset(new(1970, 01, 01)), ["property3"] = new DateTime(2018, 04, 03), }, // Nested map - new Dictionary - { + new() { ["property1"] = new Dictionary { ["innerProperty1"] = "innerValue1" @@ -154,8 +148,7 @@ public static IEnumerable WriteMapAsJsonShouldMatchExpectedTestCasesCo }, // Nested map and list - new Dictionary - { + new() { ["property1"] = new Dictionary(), ["property2"] = new List(), ["property3"] = new List @@ -194,7 +187,7 @@ private void WriteValueRecursive(OpenApiJsonWriter writer, object value) writer.WriteValue(value); } else if (value.GetType().IsGenericType && - (typeof(IDictionary<,>).IsAssignableFrom(value.GetType().GetGenericTypeDefinition()) || + (typeof(Dictionary<,>).IsAssignableFrom(value.GetType().GetGenericTypeDefinition()) || typeof(Dictionary<,>).IsAssignableFrom(value.GetType().GetGenericTypeDefinition()))) { writer.WriteStartObject(); @@ -221,7 +214,7 @@ private void WriteValueRecursive(OpenApiJsonWriter writer, object value) [Theory] [MemberData(nameof(WriteMapAsJsonShouldMatchExpectedTestCasesSimple))] [MemberData(nameof(WriteMapAsJsonShouldMatchExpectedTestCasesComplex))] - public void WriteMapAsJsonShouldMatchExpected(IDictionary inputMap, bool produceTerseOutput) + public void WriteMapAsJsonShouldMatchExpected(Dictionary inputMap, bool produceTerseOutput) { // Arrange using var outputString = new StringWriter(CultureInfo.InvariantCulture); @@ -325,12 +318,12 @@ public void OpenApiJsonWriterOutputsValidJsonValueWhenSchemaHasNanOrInfinityValu // Arrange var schema = new OpenApiSchema { - Enum = new List - { + Enum = + [ new OpenApiAny("NaN").Node, new OpenApiAny("Infinity").Node, new OpenApiAny("-Infinity").Node - } + ] }; // Act diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiYamlWriterTests.cs b/test/Microsoft.OpenApi.Tests/Writers/OpenApiYamlWriterTests.cs index 1f4d45e81..dd5608f53 100644 --- a/test/Microsoft.OpenApi.Tests/Writers/OpenApiYamlWriterTests.cs +++ b/test/Microsoft.OpenApi.Tests/Writers/OpenApiYamlWriterTests.cs @@ -9,6 +9,7 @@ using System.Net.Http; using System.Threading.Tasks; using Microsoft.OpenApi.Models; +using Microsoft.OpenApi.Models.Interfaces; using Microsoft.OpenApi.Models.References; using Microsoft.OpenApi.Writers; using Xunit; @@ -276,7 +277,7 @@ private void WriteValueRecursive(OpenApiYamlWriter writer, object value) writer.WriteValue(value); } else if (value.GetType().IsGenericType && - (typeof(IDictionary<,>).IsAssignableFrom(value.GetType().GetGenericTypeDefinition()) || + (typeof(Dictionary<,>).IsAssignableFrom(value.GetType().GetGenericTypeDefinition()) || typeof(Dictionary<,>).IsAssignableFrom(value.GetType().GetGenericTypeDefinition()))) { writer.WriteStartObject(); @@ -303,7 +304,7 @@ private void WriteValueRecursive(OpenApiYamlWriter writer, object value) [Theory] [MemberData(nameof(WriteMapAsYamlShouldMatchExpectedTestCasesSimple))] [MemberData(nameof(WriteMapAsYamlShouldMatchExpectedTestCasesComplex))] - public void WriteMapAsYamlShouldMatchExpected(IDictionary inputMap, string expectedYaml) + public void WriteMapAsYamlShouldMatchExpected(Dictionary inputMap, string expectedYaml) { // Arrange var outputString = new StringWriter(CultureInfo.InvariantCulture); @@ -456,14 +457,16 @@ private static OpenApiDocument CreateDocWithSimpleSchemaToInline() { ["/"] = new OpenApiPathItem() { - Operations = { + Operations = new() + { [HttpMethod.Get] = new() { Responses = { ["200"] = new OpenApiResponse() { Description = "OK", - Content = { + Content = new() + { ["application/json"] = new() { Schema = new OpenApiSchemaReference("thing") @@ -477,8 +480,10 @@ private static OpenApiDocument CreateDocWithSimpleSchemaToInline() }, Components = new() { - Schemas = { - ["thing"] = thingSchema} + Schemas = new() + { + ["thing"] = thingSchema + } } }; doc.RegisterComponents(); From 4bcbd51caff689a73e90efbc08f683383741e004 Mon Sep 17 00:00:00 2001 From: dldl-cmd <76129819+dldl-cmd@users.noreply.github.com> Date: Wed, 9 Apr 2025 11:35:53 +0200 Subject: [PATCH 058/984] fix: relative references in subdirectory documents are not loading #1674 (#2243) * Fix: relative references in subdirectory documents are not loading #1674 Use OpenApiDocuments BaseUri as location of the document. This allows to have during loading further documents a base Url for retrieval, which can be combined with a relative Uri to get an absolute. * PR feedback: remove unnecessary variable * Fix loading on linux --- .../OpenApiYamlReader.cs | 12 ++-- .../Interfaces/IOpenApiReader.cs | 7 +- .../Interfaces/IOpenApiVersionService.cs | 4 +- .../Interfaces/IStreamLoader.cs | 4 +- .../Models/OpenApiDocument.cs | 13 ++-- .../Reader/OpenApiJsonReader.cs | 12 +++- .../Reader/OpenApiModelFactory.cs | 22 +++--- .../Reader/ParsingContext.cs | 9 +-- .../Reader/Services/DefaultStreamLoader.cs | 16 ++--- .../Reader/Services/OpenApiWorkspaceLoader.cs | 3 +- .../Reader/V2/OpenApiDocumentDeserializer.cs | 7 +- .../Reader/V2/OpenApiV2VersionService.cs | 4 +- .../Reader/V3/OpenApiDocumentDeserializer.cs | 7 +- .../Reader/V3/OpenApiV3VersionService.cs | 4 +- .../Reader/V31/OpenApiDocumentDeserializer.cs | 7 +- .../Reader/V31/OpenApiV31VersionService.cs | 4 +- .../Services/OpenApiWorkspace.cs | 27 ++++++- .../OpenApiDiagnosticTests.cs | 2 +- .../OpenApiWorkspaceStreamTests.cs | 70 +++++++++++++++++-- .../V31Tests/OpenApiDocumentTests.cs | 7 +- .../Directory/Pets.yaml | 23 ++++++ .../Directory/PetsPage.yaml | 16 +++++ .../Root.yaml | 16 +++++ .../PublicApi/PublicApi.approved.txt | 18 ++--- 24 files changed, 241 insertions(+), 73 deletions(-) create mode 100644 test/Microsoft.OpenApi.Readers.Tests/V3Tests/Samples/OpenApiWorkspace/ExternalReferencesInSubDirectories/Directory/Pets.yaml create mode 100644 test/Microsoft.OpenApi.Readers.Tests/V3Tests/Samples/OpenApiWorkspace/ExternalReferencesInSubDirectories/Directory/PetsPage.yaml create mode 100644 test/Microsoft.OpenApi.Readers.Tests/V3Tests/Samples/OpenApiWorkspace/ExternalReferencesInSubDirectories/Root.yaml diff --git a/src/Microsoft.OpenApi.YamlReader/OpenApiYamlReader.cs b/src/Microsoft.OpenApi.YamlReader/OpenApiYamlReader.cs index f6019a91e..a7f888484 100644 --- a/src/Microsoft.OpenApi.YamlReader/OpenApiYamlReader.cs +++ b/src/Microsoft.OpenApi.YamlReader/OpenApiYamlReader.cs @@ -26,25 +26,27 @@ public class OpenApiYamlReader : IOpenApiReader /// public async Task ReadAsync(Stream input, + Uri location, OpenApiReaderSettings settings, CancellationToken cancellationToken = default) { if (input is null) throw new ArgumentNullException(nameof(input)); if (input is MemoryStream memoryStream) { - return Read(memoryStream, settings); + return Read(memoryStream, location, settings); } else { using var preparedStream = new MemoryStream(); await input.CopyToAsync(preparedStream, copyBufferSize, cancellationToken).ConfigureAwait(false); preparedStream.Position = 0; - return Read(preparedStream, settings); + return Read(preparedStream, location, settings); } } /// public ReadResult Read(MemoryStream input, + Uri location, OpenApiReaderSettings settings) { if (input is null) throw new ArgumentNullException(nameof(input)); @@ -74,13 +76,13 @@ public ReadResult Read(MemoryStream input, }; } - return Read(jsonNode, settings); + return Read(jsonNode, location, settings); } /// - public static ReadResult Read(JsonNode jsonNode, OpenApiReaderSettings settings) + public static ReadResult Read(JsonNode jsonNode, Uri location, OpenApiReaderSettings settings) { - return _jsonReader.Read(jsonNode, settings); + return _jsonReader.Read(jsonNode, location, settings); } /// diff --git a/src/Microsoft.OpenApi/Interfaces/IOpenApiReader.cs b/src/Microsoft.OpenApi/Interfaces/IOpenApiReader.cs index 687599caa..d17371a68 100644 --- a/src/Microsoft.OpenApi/Interfaces/IOpenApiReader.cs +++ b/src/Microsoft.OpenApi/Interfaces/IOpenApiReader.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. +using System; using System.IO; using System.Threading; using System.Threading.Tasks; @@ -18,18 +19,20 @@ public interface IOpenApiReader /// Async method to reads the stream and parse it into an Open API document. /// /// The stream input. + /// Location of where the document that is getting loaded is saved /// The OpenApi reader settings. /// Propagates notification that an operation should be cancelled. /// - Task ReadAsync(Stream input, OpenApiReaderSettings settings, CancellationToken cancellationToken = default); + Task ReadAsync(Stream input, Uri location, OpenApiReaderSettings settings, CancellationToken cancellationToken = default); /// /// Provides a synchronous method to read the input memory stream and parse it into an Open API document. /// /// + /// Location of where the document that is getting loaded is saved /// /// - ReadResult Read(MemoryStream input, OpenApiReaderSettings settings); + ReadResult Read(MemoryStream input, Uri location, OpenApiReaderSettings settings); /// /// Reads the MemoryStream and parses the fragment of an OpenAPI description into an Open API Element. diff --git a/src/Microsoft.OpenApi/Interfaces/IOpenApiVersionService.cs b/src/Microsoft.OpenApi/Interfaces/IOpenApiVersionService.cs index 64049483e..56df6f9b0 100644 --- a/src/Microsoft.OpenApi/Interfaces/IOpenApiVersionService.cs +++ b/src/Microsoft.OpenApi/Interfaces/IOpenApiVersionService.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. +using System; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Reader.ParseNodes; @@ -24,8 +25,9 @@ internal interface IOpenApiVersionService /// Converts a generic RootNode instance into a strongly typed OpenApiDocument /// /// RootNode containing the information to be converted into an OpenAPI Document + /// Location of where the document that is getting loaded is saved /// Instance of OpenApiDocument populated with data from rootNode - OpenApiDocument LoadDocument(RootNode rootNode); + OpenApiDocument LoadDocument(RootNode rootNode, Uri location); /// /// Gets the description and summary scalar values in a reference object for V3.1 support diff --git a/src/Microsoft.OpenApi/Interfaces/IStreamLoader.cs b/src/Microsoft.OpenApi/Interfaces/IStreamLoader.cs index e6438bac1..d56f6075e 100644 --- a/src/Microsoft.OpenApi/Interfaces/IStreamLoader.cs +++ b/src/Microsoft.OpenApi/Interfaces/IStreamLoader.cs @@ -17,9 +17,11 @@ public interface IStreamLoader /// /// Use Uri to locate data and convert into an input object. /// + /// Base URL of parent to which a relative reference could be loaded. + /// If the is an absolute parameter the value of this parameter will be ignored /// Identifier of some source of an OpenAPI Description /// The cancellation token. /// A data object that can be processed by a reader to generate an - Task LoadAsync(Uri uri, CancellationToken cancellationToken = default); + Task LoadAsync(Uri baseUrl, Uri uri, CancellationToken cancellationToken = default); } } diff --git a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs index 443123f9a..0f15a27d9 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs @@ -109,9 +109,9 @@ public HashSet? Tags public Dictionary? Metadata { get; set; } /// - /// Implements IBaseDocument + /// Absolute location of the document or a generated placeholder if location is not given /// - public Uri BaseUri { get; } + public Uri BaseUri { get; internal set; } /// /// Parameter-less constructor @@ -571,14 +571,15 @@ private static string ConvertByteArrayToString(byte[] hash) } else { - string relativePath = OpenApiConstants.ComponentsSegment + reference.Type.GetDisplayName() + "/" + id; + string relativePath = $"#{OpenApiConstants.ComponentsSegment}{reference.Type.GetDisplayName()}/{id}"; + Uri? externalResourceUri = useExternal ? Workspace?.GetDocumentId(reference.ExternalResource) : null; - uriLocation = useExternal - ? Workspace?.GetDocumentId(reference.ExternalResource)?.OriginalString + relativePath + uriLocation = useExternal && externalResourceUri is not null + ? externalResourceUri.AbsoluteUri + relativePath : BaseUri + relativePath; } - return Workspace?.ResolveReference(uriLocation); + return Workspace?.ResolveReference(new Uri(uriLocation).AbsoluteUri); } /// diff --git a/src/Microsoft.OpenApi/Reader/OpenApiJsonReader.cs b/src/Microsoft.OpenApi/Reader/OpenApiJsonReader.cs index 87a56d90d..3432875a1 100644 --- a/src/Microsoft.OpenApi/Reader/OpenApiJsonReader.cs +++ b/src/Microsoft.OpenApi/Reader/OpenApiJsonReader.cs @@ -25,9 +25,11 @@ public class OpenApiJsonReader : IOpenApiReader /// Reads the memory stream input and parses it into an Open API document. /// /// Memory stream containing OpenAPI description to parse. + /// Location of where the document that is getting loaded is saved /// The Reader settings to be used during parsing. /// public ReadResult Read(MemoryStream input, + Uri location, OpenApiReaderSettings settings) { if (input is null) throw new ArgumentNullException(nameof(input)); @@ -52,16 +54,18 @@ public ReadResult Read(MemoryStream input, }; } - return Read(jsonNode, settings); + return Read(jsonNode, location, settings); } /// /// Parses the JsonNode input into an Open API document. /// /// The JsonNode input. + /// Location of where the document that is getting loaded is saved /// The Reader settings to be used during parsing. /// public ReadResult Read(JsonNode jsonNode, + Uri location, OpenApiReaderSettings settings) { if (jsonNode is null) throw new ArgumentNullException(nameof(jsonNode)); @@ -79,7 +83,7 @@ public ReadResult Read(JsonNode jsonNode, try { // Parse the OpenAPI Document - document = context.Parse(jsonNode); + document = context.Parse(jsonNode, location); document.SetReferenceHostDocument(); } catch (OpenApiException ex) @@ -115,10 +119,12 @@ public ReadResult Read(JsonNode jsonNode, /// Reads the stream input asynchronously and parses it into an Open API document. /// /// Memory stream containing OpenAPI description to parse. + /// Location of where the document that is getting loaded is saved /// The Reader settings to be used during parsing. /// Propagates notifications that operations should be cancelled. /// public async Task ReadAsync(Stream input, + Uri location, OpenApiReaderSettings settings, CancellationToken cancellationToken = default) { @@ -144,7 +150,7 @@ public async Task ReadAsync(Stream input, }; } - return Read(jsonNode, settings); + return Read(jsonNode, location, settings); } /// diff --git a/src/Microsoft.OpenApi/Reader/OpenApiModelFactory.cs b/src/Microsoft.OpenApi/Reader/OpenApiModelFactory.cs index e370720e3..dc206c47e 100644 --- a/src/Microsoft.OpenApi/Reader/OpenApiModelFactory.cs +++ b/src/Microsoft.OpenApi/Reader/OpenApiModelFactory.cs @@ -240,7 +240,13 @@ private static async Task InternalLoadAsync(Stream input, string for { settings ??= DefaultReaderSettings.Value; var reader = settings.GetReader(format); - var readResult = await reader.ReadAsync(input, settings, cancellationToken).ConfigureAwait(false); + var location = new Uri(OpenApiConstants.BaseRegistryUri); + if (input is FileStream fileStream) + { + location = new Uri(fileStream.Name); + } + + var readResult = await reader.ReadAsync(input, location, settings, cancellationToken).ConfigureAwait(false); if (settings.LoadExternalRefs) { @@ -258,13 +264,10 @@ private static async Task InternalLoadAsync(Stream input, string for private static async Task LoadExternalRefsAsync(OpenApiDocument? document, OpenApiReaderSettings settings, string? format = null, CancellationToken token = default) { - // Create workspace for all documents to live in. - var baseUrl = settings.BaseUrl ?? new Uri(OpenApiConstants.BaseRegistryUri); - var openApiWorkSpace = new OpenApiWorkspace(baseUrl); - - // Load this root document into the workspace - var streamLoader = new DefaultStreamLoader(baseUrl, settings.HttpClient); - var workspaceLoader = new OpenApiWorkspaceLoader(openApiWorkSpace, settings.CustomExternalLoader ?? streamLoader, settings); + // Load this document into the workspace + var streamLoader = new DefaultStreamLoader(settings.HttpClient); + var workspace = document?.Workspace ?? new OpenApiWorkspace(); + var workspaceLoader = new OpenApiWorkspaceLoader(workspace, settings.CustomExternalLoader ?? streamLoader, settings); return await workspaceLoader.LoadAsync(new OpenApiReference() { ExternalResource = "/" }, document, format ?? OpenApiConstants.Json, null, token).ConfigureAwait(false); } @@ -280,8 +283,9 @@ private static ReadResult InternalLoad(MemoryStream input, string format, OpenAp throw new ArgumentException($"Cannot parse the stream: {nameof(input)} is empty or contains no elements."); } + var location = new Uri(OpenApiConstants.BaseRegistryUri); var reader = settings.GetReader(format); - var readResult = reader.Read(input, settings); + var readResult = reader.Read(input, location, settings); return readResult; } diff --git a/src/Microsoft.OpenApi/Reader/ParsingContext.cs b/src/Microsoft.OpenApi/Reader/ParsingContext.cs index 93d9517b9..68d06933a 100644 --- a/src/Microsoft.OpenApi/Reader/ParsingContext.cs +++ b/src/Microsoft.OpenApi/Reader/ParsingContext.cs @@ -62,8 +62,9 @@ public ParsingContext(OpenApiDiagnostic diagnostic) /// Initiates the parsing process. Not thread safe and should only be called once on a parsing context /// /// Set of Json nodes to parse. + /// Location of where the document that is getting loaded is saved /// An OpenApiDocument populated based on the passed yamlDocument - public OpenApiDocument Parse(JsonNode jsonNode) + public OpenApiDocument Parse(JsonNode jsonNode, Uri location) { RootNode = new RootNode(this, jsonNode); @@ -75,20 +76,20 @@ public OpenApiDocument Parse(JsonNode jsonNode) { case string version when version.is2_0(): VersionService = new OpenApiV2VersionService(Diagnostic); - doc = VersionService.LoadDocument(RootNode); + doc = VersionService.LoadDocument(RootNode, location); this.Diagnostic.SpecificationVersion = OpenApiSpecVersion.OpenApi2_0; ValidateRequiredFields(doc, version); break; case string version when version.is3_0(): VersionService = new OpenApiV3VersionService(Diagnostic); - doc = VersionService.LoadDocument(RootNode); + doc = VersionService.LoadDocument(RootNode, location); this.Diagnostic.SpecificationVersion = version.is3_1() ? OpenApiSpecVersion.OpenApi3_1 : OpenApiSpecVersion.OpenApi3_0; ValidateRequiredFields(doc, version); break; case string version when version.is3_1(): VersionService = new OpenApiV31VersionService(Diagnostic); - doc = VersionService.LoadDocument(RootNode); + doc = VersionService.LoadDocument(RootNode, location); this.Diagnostic.SpecificationVersion = OpenApiSpecVersion.OpenApi3_1; ValidateRequiredFields(doc, version); break; diff --git a/src/Microsoft.OpenApi/Reader/Services/DefaultStreamLoader.cs b/src/Microsoft.OpenApi/Reader/Services/DefaultStreamLoader.cs index ad36e5554..374e00f49 100644 --- a/src/Microsoft.OpenApi/Reader/Services/DefaultStreamLoader.cs +++ b/src/Microsoft.OpenApi/Reader/Services/DefaultStreamLoader.cs @@ -17,30 +17,24 @@ namespace Microsoft.OpenApi.Reader.Services /// public class DefaultStreamLoader : IStreamLoader { - private readonly Uri baseUrl; private readonly HttpClient _httpClient; /// /// The default stream loader /// - /// /// The HttpClient to use to retrieve documents when needed - public DefaultStreamLoader(Uri baseUrl, HttpClient httpClient) + public DefaultStreamLoader(HttpClient httpClient) { - this.baseUrl = baseUrl; _httpClient = Utils.CheckArgumentNull(httpClient); } /// - public async Task LoadAsync(Uri uri, CancellationToken cancellationToken = default) + public async Task LoadAsync(Uri baseUrl, Uri uri, CancellationToken cancellationToken = default) { - var absoluteUri = (baseUrl.AbsoluteUri.Equals(OpenApiConstants.BaseRegistryUri), baseUrl.IsAbsoluteUri, uri.IsAbsoluteUri) switch + var absoluteUri = baseUrl.AbsoluteUri.Equals(OpenApiConstants.BaseRegistryUri) switch { - (true, _, _) => new Uri(Path.Combine(Directory.GetCurrentDirectory(), uri.ToString())), - // this overcomes a URI concatenation issue for local paths on linux OSes - (_, true, false) when baseUrl.Scheme.Equals("file", StringComparison.OrdinalIgnoreCase) && !RuntimeInformation.IsOSPlatform(OSPlatform.Windows) => - new Uri(Path.Combine(baseUrl.AbsoluteUri, uri.ToString())), - (_, _, _) => new Uri(baseUrl, uri), + true => new Uri(Path.Combine(Directory.GetCurrentDirectory(), uri.ToString())), + _ => new Uri(baseUrl, uri), }; return absoluteUri.Scheme switch diff --git a/src/Microsoft.OpenApi/Reader/Services/OpenApiWorkspaceLoader.cs b/src/Microsoft.OpenApi/Reader/Services/OpenApiWorkspaceLoader.cs index 75dd43512..a9cba7989 100644 --- a/src/Microsoft.OpenApi/Reader/Services/OpenApiWorkspaceLoader.cs +++ b/src/Microsoft.OpenApi/Reader/Services/OpenApiWorkspaceLoader.cs @@ -48,7 +48,8 @@ internal async Task LoadAsync(OpenApiReference reference, // If not already in workspace, load it and process references if (item.ExternalResource is not null && !_workspace.Contains(item.ExternalResource)) { - var input = await _loader.LoadAsync(new(item.ExternalResource, UriKind.RelativeOrAbsolute), cancellationToken).ConfigureAwait(false); + var uri = new Uri(item.ExternalResource, UriKind.RelativeOrAbsolute); + var input = await _loader.LoadAsync(item.HostDocument!.BaseUri, uri, cancellationToken).ConfigureAwait(false); var result = await OpenApiDocument.LoadAsync(input, format, _readerSettings, cancellationToken).ConfigureAwait(false); // Merge diagnostics if (result.Diagnostic != null) diff --git a/src/Microsoft.OpenApi/Reader/V2/OpenApiDocumentDeserializer.cs b/src/Microsoft.OpenApi/Reader/V2/OpenApiDocumentDeserializer.cs index 369d03470..44dc3f313 100644 --- a/src/Microsoft.OpenApi/Reader/V2/OpenApiDocumentDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V2/OpenApiDocumentDeserializer.cs @@ -227,9 +227,12 @@ private static string BuildUrl(string? scheme, string? host, string? basePath) return uriBuilder.ToString(); } - public static OpenApiDocument LoadOpenApi(RootNode rootNode) + public static OpenApiDocument LoadOpenApi(RootNode rootNode, Uri location) { - var openApiDoc = new OpenApiDocument(); + var openApiDoc = new OpenApiDocument + { + BaseUri = location + }; var openApiNode = rootNode.GetMap(); diff --git a/src/Microsoft.OpenApi/Reader/V2/OpenApiV2VersionService.cs b/src/Microsoft.OpenApi/Reader/V2/OpenApiV2VersionService.cs index d92e9ce78..ec46036e0 100644 --- a/src/Microsoft.OpenApi/Reader/V2/OpenApiV2VersionService.cs +++ b/src/Microsoft.OpenApi/Reader/V2/OpenApiV2VersionService.cs @@ -50,9 +50,9 @@ public OpenApiV2VersionService(OpenApiDiagnostic diagnostic) [typeof(OpenApiXml)] = OpenApiV2Deserializer.LoadXml }; - public OpenApiDocument LoadDocument(RootNode rootNode) + public OpenApiDocument LoadDocument(RootNode rootNode, Uri location) { - return OpenApiV2Deserializer.LoadOpenApi(rootNode); + return OpenApiV2Deserializer.LoadOpenApi(rootNode, location); } public T? LoadElement(ParseNode node, OpenApiDocument doc) where T : IOpenApiElement diff --git a/src/Microsoft.OpenApi/Reader/V3/OpenApiDocumentDeserializer.cs b/src/Microsoft.OpenApi/Reader/V3/OpenApiDocumentDeserializer.cs index 6e5fb952b..eee2b6c3d 100644 --- a/src/Microsoft.OpenApi/Reader/V3/OpenApiDocumentDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V3/OpenApiDocumentDeserializer.cs @@ -38,9 +38,12 @@ internal static partial class OpenApiV3Deserializer {s => s.StartsWith(OpenApiConstants.ExtensionFieldNamePrefix, StringComparison.OrdinalIgnoreCase), (o, p, n, _) => o.AddExtension(p, LoadExtension(p, n))} }; - public static OpenApiDocument LoadOpenApi(RootNode rootNode) + public static OpenApiDocument LoadOpenApi(RootNode rootNode, Uri location) { - var openApiDoc = new OpenApiDocument(); + var openApiDoc = new OpenApiDocument + { + BaseUri = location + }; var openApiNode = rootNode.GetMap(); ParseMap(openApiNode, openApiDoc, _openApiFixedFields, _openApiPatternFields, openApiDoc); diff --git a/src/Microsoft.OpenApi/Reader/V3/OpenApiV3VersionService.cs b/src/Microsoft.OpenApi/Reader/V3/OpenApiV3VersionService.cs index 364eb1d54..34ad86fe3 100644 --- a/src/Microsoft.OpenApi/Reader/V3/OpenApiV3VersionService.cs +++ b/src/Microsoft.OpenApi/Reader/V3/OpenApiV3VersionService.cs @@ -64,9 +64,9 @@ public OpenApiV3VersionService(OpenApiDiagnostic diagnostic) [typeof(OpenApiSchemaReference)] = OpenApiV3Deserializer.LoadMapping }; - public OpenApiDocument LoadDocument(RootNode rootNode) + public OpenApiDocument LoadDocument(RootNode rootNode, Uri location) { - return OpenApiV3Deserializer.LoadOpenApi(rootNode); + return OpenApiV3Deserializer.LoadOpenApi(rootNode, location); } public T LoadElement(ParseNode node, OpenApiDocument doc) where T : IOpenApiElement diff --git a/src/Microsoft.OpenApi/Reader/V31/OpenApiDocumentDeserializer.cs b/src/Microsoft.OpenApi/Reader/V31/OpenApiDocumentDeserializer.cs index 0abe92234..ffc2bc175 100644 --- a/src/Microsoft.OpenApi/Reader/V31/OpenApiDocumentDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V31/OpenApiDocumentDeserializer.cs @@ -36,9 +36,12 @@ internal static partial class OpenApiV31Deserializer {s => s.StartsWith(OpenApiConstants.ExtensionFieldNamePrefix, StringComparison.OrdinalIgnoreCase), (o, p, n, _) => o.AddExtension(p, LoadExtension(p, n))} }; - public static OpenApiDocument LoadOpenApi(RootNode rootNode) + public static OpenApiDocument LoadOpenApi(RootNode rootNode, Uri location) { - var openApiDoc = new OpenApiDocument(); + var openApiDoc = new OpenApiDocument + { + BaseUri = location + }; var openApiNode = rootNode.GetMap(); ParseMap(openApiNode, openApiDoc, _openApiFixedFields, _openApiPatternFields, openApiDoc); diff --git a/src/Microsoft.OpenApi/Reader/V31/OpenApiV31VersionService.cs b/src/Microsoft.OpenApi/Reader/V31/OpenApiV31VersionService.cs index da404f4c0..90d8e86aa 100644 --- a/src/Microsoft.OpenApi/Reader/V31/OpenApiV31VersionService.cs +++ b/src/Microsoft.OpenApi/Reader/V31/OpenApiV31VersionService.cs @@ -63,9 +63,9 @@ public OpenApiV31VersionService(OpenApiDiagnostic diagnostic) [typeof(OpenApiSchemaReference)] = OpenApiV31Deserializer.LoadMapping }; - public OpenApiDocument LoadDocument(RootNode rootNode) + public OpenApiDocument LoadDocument(RootNode rootNode, Uri location) { - return OpenApiV31Deserializer.LoadOpenApi(rootNode); + return OpenApiV31Deserializer.LoadOpenApi(rootNode, location); } public T LoadElement(ParseNode node, OpenApiDocument doc) where T : IOpenApiElement diff --git a/src/Microsoft.OpenApi/Services/OpenApiWorkspace.cs b/src/Microsoft.OpenApi/Services/OpenApiWorkspace.cs index a8ffde23d..5519696d9 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiWorkspace.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiWorkspace.cs @@ -18,7 +18,30 @@ public class OpenApiWorkspace { private readonly Dictionary _documentsIdRegistry = new(); private readonly Dictionary _artifactsRegistry = new(); - private readonly Dictionary _IOpenApiReferenceableRegistry = new(); + private readonly Dictionary _IOpenApiReferenceableRegistry = new(new UriWithFragmentEquailityComparer()); + + private class UriWithFragmentEquailityComparer : IEqualityComparer + { + public bool Equals(Uri? x, Uri? y) + { + if (ReferenceEquals(x, y)) + { + return true; + } + + if (x is null || y is null) + { + return false; + } + + return x.AbsoluteUri == y.AbsoluteUri; + } + + public int GetHashCode(Uri obj) + { + return obj.AbsoluteUri.GetHashCode(); + } + } /// /// The base location from where all relative references are resolved @@ -171,7 +194,7 @@ public void RegisterComponents(OpenApiDocument document) private static string getBaseUri(OpenApiDocument openApiDocument) { - return openApiDocument.BaseUri + OpenApiConstants.ComponentsSegment; + return openApiDocument.BaseUri + "#" + OpenApiConstants.ComponentsSegment; } /// diff --git a/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiDiagnosticTests.cs b/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiDiagnosticTests.cs index 1171e8c20..f275ebb2a 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiDiagnosticTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiDiagnosticTests.cs @@ -62,7 +62,7 @@ public Stream Load(Uri uri) return null; } - public Task LoadAsync(Uri uri, CancellationToken cancellationToken = default) + public Task LoadAsync(Uri baseUrl, Uri uri, CancellationToken cancellationToken = default) { var path = new Uri(new("http://example.org/OpenApiReaderTests/Samples/OpenApiDiagnosticReportMerged/"), uri).AbsolutePath; path = path[1..]; // remove leading slash diff --git a/test/Microsoft.OpenApi.Readers.Tests/OpenApiWorkspaceTests/OpenApiWorkspaceStreamTests.cs b/test/Microsoft.OpenApi.Readers.Tests/OpenApiWorkspaceTests/OpenApiWorkspaceStreamTests.cs index 720eade40..671a4a9eb 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/OpenApiWorkspaceTests/OpenApiWorkspaceStreamTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/OpenApiWorkspaceTests/OpenApiWorkspaceStreamTests.cs @@ -1,9 +1,13 @@ -using System; +using System; +using System.Collections.Generic; using System.IO; +using System.Net.Http; using System.Threading; using System.Threading.Tasks; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; +using Microsoft.OpenApi.Models.Interfaces; +using Microsoft.OpenApi.Models.References; using Microsoft.OpenApi.Reader; using Xunit; @@ -59,14 +63,70 @@ public async Task LoadDocumentWithExternalReferenceShouldLoadBothDocumentsIntoWo result = await OpenApiDocument.LoadAsync("V3Tests/Samples/OpenApiWorkspace/TodoMain.yaml", settings); var externalDocBaseUri = result.Document.Workspace.GetDocumentId("./TodoComponents.yaml"); - var schemasPath = "/components/schemas/"; - var parametersPath = "/components/parameters/"; + var schemasPath = "#/components/schemas/"; + var parametersPath = "#/components/parameters/"; Assert.NotNull(externalDocBaseUri); Assert.True(result.Document.Workspace.Contains(externalDocBaseUri + schemasPath + "todo")); Assert.True(result.Document.Workspace.Contains(externalDocBaseUri + schemasPath + "entity")); Assert.True(result.Document.Workspace.Contains(externalDocBaseUri + parametersPath + "filter")); } + + [Fact] + public async Task LoadDocumentWithExternalReferencesInSubDirectories() + { + var sampleFolderPath = $"V3Tests/Samples/OpenApiWorkspace/ExternalReferencesInSubDirectories"; + var referenceBaseUri = "file://" + Path.GetFullPath(sampleFolderPath); + + // Create a reader that will resolve all references also of documentes located in the non-root directory + var settings = new OpenApiReaderSettings() + { + LoadExternalRefs = true, + BaseUrl = new Uri("file://") + }; + settings.AddYamlReader(); + + // Act + var result = await OpenApiDocument.LoadAsync($"{sampleFolderPath}/Root.yaml", settings); + var document = result.Document; + var workspace = result.Document.Workspace; + + // Assert + Assert.True(workspace.Contains($"{Path.Combine(referenceBaseUri, "Directory", "PetsPage.yaml")}#/components/schemas/PetsPage")); + Assert.True(workspace.Contains($"{Path.Combine(referenceBaseUri, "Directory", "Pets.yaml")}#/components/schemas/Pets")); + Assert.True(workspace.Contains($"{Path.Combine(referenceBaseUri, "Directory", "Pets.yaml")}#/components/schemas/Pet")); + + var operationResponseSchema = document.Paths["/pets"].Operations[HttpMethod.Get].Responses["200"].Content["application/json"].Schema; + Assert.IsType(operationResponseSchema); + + var petsSchema = operationResponseSchema.Properties["pets"]; + Assert.IsType(petsSchema); + Assert.Equal(JsonSchemaType.Array, petsSchema.Type); + + var petSchema = petsSchema.Items; + Assert.IsType(petSchema); + + Assert.Equivalent(new OpenApiSchema + { + Required = new HashSet { "id", "name" }, + Properties = new Dictionary + { + ["id"] = new OpenApiSchema + { + Type = JsonSchemaType.Integer, + Format = "int64" + }, + ["name"] = new OpenApiSchema + { + Type = JsonSchemaType.String + }, + ["tag"] = new OpenApiSchema + { + Type = JsonSchemaType.String + } + } + }, petSchema); + } } public class MockLoader : IStreamLoader @@ -76,7 +136,7 @@ public Stream Load(Uri uri) return null; } - public Task LoadAsync(Uri uri, CancellationToken cancellationToken = default) + public Task LoadAsync(Uri baseUrl, Uri uri, CancellationToken cancellationToken = default) { return Task.FromResult(null); } @@ -89,7 +149,7 @@ public Stream Load(Uri uri) return null; } - public Task LoadAsync(Uri uri, CancellationToken cancellationToken = default) + public Task LoadAsync(Uri baseUrl, Uri uri, CancellationToken cancellationToken = default) { var path = new Uri(new("http://example.org/V3Tests/Samples/OpenApiWorkspace/"), uri).AbsolutePath; path = path[1..]; // remove leading slash diff --git a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentTests.cs index fa99dcd1b..0919471b2 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentTests.cs @@ -528,7 +528,12 @@ public async Task ExternalDocumentDereferenceToOpenApiDocumentUsingJsonPointerWo var responseSchema = result.Document.Paths["/resource"].Operations[HttpMethod.Get].Responses["200"].Content["application/json"].Schema; // Assert - result.Document.Workspace.Contains("./externalResource.yaml"); + var externalResourceUri = new Uri( + "file://" + + Path.Combine(Path.GetFullPath(SampleFolderPath), + "externalResource.yaml#/components/schemas/todo")).AbsoluteUri; + + Assert.True(result.Document.Workspace.Contains(externalResourceUri)); Assert.Equal(2, responseSchema.Properties.Count); // reference has been resolved } diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/Samples/OpenApiWorkspace/ExternalReferencesInSubDirectories/Directory/Pets.yaml b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/Samples/OpenApiWorkspace/ExternalReferencesInSubDirectories/Directory/Pets.yaml new file mode 100644 index 000000000..ddf4c6cc3 --- /dev/null +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/Samples/OpenApiWorkspace/ExternalReferencesInSubDirectories/Directory/Pets.yaml @@ -0,0 +1,23 @@ +openapi: 3.0.0 +info: + version: 1.0.0 + title: Pet(s) Schema +paths: {} +components: + schemas: + Pets: + type: array + items: + "$ref": "#/components/schemas/Pet" + Pet: + required: + - id + - name + properties: + id: + type: integer + format: int64 + name: + type: string + tag: + type: string \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/Samples/OpenApiWorkspace/ExternalReferencesInSubDirectories/Directory/PetsPage.yaml b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/Samples/OpenApiWorkspace/ExternalReferencesInSubDirectories/Directory/PetsPage.yaml new file mode 100644 index 000000000..139c6d4e1 --- /dev/null +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/Samples/OpenApiWorkspace/ExternalReferencesInSubDirectories/Directory/PetsPage.yaml @@ -0,0 +1,16 @@ +openapi: 3.0.0 +info: + version: 1.0.0 + title: AllPets Schema +paths: {} +components: + schemas: + PetsPage: + type: object + properties: + pageNumber: + type: integer + minimum: 0 + maximum: 100 + pets: + "$ref": "./Pets.yaml#/components/schemas/Pets" \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/Samples/OpenApiWorkspace/ExternalReferencesInSubDirectories/Root.yaml b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/Samples/OpenApiWorkspace/ExternalReferencesInSubDirectories/Root.yaml new file mode 100644 index 000000000..97d386192 --- /dev/null +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/Samples/OpenApiWorkspace/ExternalReferencesInSubDirectories/Root.yaml @@ -0,0 +1,16 @@ +openapi: 3.0.0 +info: + version: 1.0.0 + title: Example using relative references into sub directories +paths: + "/pets": + get: + summary: List all pets + operationId: listPets + responses: + '200': + description: An array of pets + content: + application/json: + schema: + "$ref": "./Directory/PetsPage.yaml#/components/schemas/PetsPage" \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index bcec5fb01..4a8fcea74 100644 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -217,8 +217,8 @@ namespace Microsoft.OpenApi.Interfaces } public interface IOpenApiReader { - Microsoft.OpenApi.Reader.ReadResult Read(System.IO.MemoryStream input, Microsoft.OpenApi.Reader.OpenApiReaderSettings settings); - System.Threading.Tasks.Task ReadAsync(System.IO.Stream input, Microsoft.OpenApi.Reader.OpenApiReaderSettings settings, System.Threading.CancellationToken cancellationToken = default); + Microsoft.OpenApi.Reader.ReadResult Read(System.IO.MemoryStream input, System.Uri location, Microsoft.OpenApi.Reader.OpenApiReaderSettings settings); + System.Threading.Tasks.Task ReadAsync(System.IO.Stream input, System.Uri location, Microsoft.OpenApi.Reader.OpenApiReaderSettings settings, System.Threading.CancellationToken cancellationToken = default); T? ReadFragment(System.IO.MemoryStream input, Microsoft.OpenApi.OpenApiSpecVersion version, Microsoft.OpenApi.Models.OpenApiDocument openApiDocument, out Microsoft.OpenApi.Reader.OpenApiDiagnostic diagnostic, Microsoft.OpenApi.Reader.OpenApiReaderSettings? settings = null) where T : Microsoft.OpenApi.Interfaces.IOpenApiElement; } @@ -247,7 +247,7 @@ namespace Microsoft.OpenApi.Interfaces } public interface IStreamLoader { - System.Threading.Tasks.Task LoadAsync(System.Uri uri, System.Threading.CancellationToken cancellationToken = default); + System.Threading.Tasks.Task LoadAsync(System.Uri baseUrl, System.Uri uri, System.Threading.CancellationToken cancellationToken = default); } } namespace Microsoft.OpenApi @@ -1441,9 +1441,9 @@ namespace Microsoft.OpenApi.Reader public class OpenApiJsonReader : Microsoft.OpenApi.Interfaces.IOpenApiReader { public OpenApiJsonReader() { } - public Microsoft.OpenApi.Reader.ReadResult Read(System.IO.MemoryStream input, Microsoft.OpenApi.Reader.OpenApiReaderSettings settings) { } - public Microsoft.OpenApi.Reader.ReadResult Read(System.Text.Json.Nodes.JsonNode jsonNode, Microsoft.OpenApi.Reader.OpenApiReaderSettings settings) { } - public System.Threading.Tasks.Task ReadAsync(System.IO.Stream input, Microsoft.OpenApi.Reader.OpenApiReaderSettings settings, System.Threading.CancellationToken cancellationToken = default) { } + public Microsoft.OpenApi.Reader.ReadResult Read(System.IO.MemoryStream input, System.Uri location, Microsoft.OpenApi.Reader.OpenApiReaderSettings settings) { } + public Microsoft.OpenApi.Reader.ReadResult Read(System.Text.Json.Nodes.JsonNode jsonNode, System.Uri location, Microsoft.OpenApi.Reader.OpenApiReaderSettings settings) { } + public System.Threading.Tasks.Task ReadAsync(System.IO.Stream input, System.Uri location, Microsoft.OpenApi.Reader.OpenApiReaderSettings settings, System.Threading.CancellationToken cancellationToken = default) { } public T? ReadFragment(System.IO.MemoryStream input, Microsoft.OpenApi.OpenApiSpecVersion version, Microsoft.OpenApi.Models.OpenApiDocument openApiDocument, out Microsoft.OpenApi.Reader.OpenApiDiagnostic diagnostic, Microsoft.OpenApi.Reader.OpenApiReaderSettings? settings = null) where T : Microsoft.OpenApi.Interfaces.IOpenApiElement { } public T? ReadFragment(System.Text.Json.Nodes.JsonNode input, Microsoft.OpenApi.OpenApiSpecVersion version, Microsoft.OpenApi.Models.OpenApiDocument openApiDocument, out Microsoft.OpenApi.Reader.OpenApiDiagnostic diagnostic, Microsoft.OpenApi.Reader.OpenApiReaderSettings? settings = null) @@ -1496,7 +1496,7 @@ namespace Microsoft.OpenApi.Reader public void EndObject() { } public T? GetFromTempStorage(string key, object? scope = null) { } public string GetLocation() { } - public Microsoft.OpenApi.Models.OpenApiDocument Parse(System.Text.Json.Nodes.JsonNode jsonNode) { } + public Microsoft.OpenApi.Models.OpenApiDocument Parse(System.Text.Json.Nodes.JsonNode jsonNode, System.Uri location) { } public T? ParseFragment(System.Text.Json.Nodes.JsonNode jsonNode, Microsoft.OpenApi.OpenApiSpecVersion version, Microsoft.OpenApi.Models.OpenApiDocument openApiDocument) where T : Microsoft.OpenApi.Interfaces.IOpenApiElement { } public void PopLoop(string loopid) { } @@ -1523,8 +1523,8 @@ namespace Microsoft.OpenApi.Reader.Services { public class DefaultStreamLoader : Microsoft.OpenApi.Interfaces.IStreamLoader { - public DefaultStreamLoader(System.Uri baseUrl, System.Net.Http.HttpClient httpClient) { } - public System.Threading.Tasks.Task LoadAsync(System.Uri uri, System.Threading.CancellationToken cancellationToken = default) { } + public DefaultStreamLoader(System.Net.Http.HttpClient httpClient) { } + public System.Threading.Tasks.Task LoadAsync(System.Uri baseUrl, System.Uri uri, System.Threading.CancellationToken cancellationToken = default) { } } } namespace Microsoft.OpenApi.Services From 33fc7cbcda71efea47070ab7a6ebf9db8787a7f8 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Wed, 9 Apr 2025 15:41:56 -0400 Subject: [PATCH 059/984] fix: renames annotations schema property to metadata to match #2241 --- .../Interfaces/IMetadataContainer.cs | 19 +++++++++---------- .../Models/Interfaces/IOpenApiSchema.cs | 7 +------ src/Microsoft.OpenApi/Models/OpenApiSchema.cs | 6 +++--- .../References/OpenApiSchemaReference.cs | 3 --- .../Models/OpenApiDocumentTests.cs | 6 +++--- .../Models/OpenApiSchemaTests.cs | 14 +++++++------- .../PublicApi/PublicApi.approved.txt | 6 ++---- 7 files changed, 25 insertions(+), 36 deletions(-) diff --git a/src/Microsoft.OpenApi/Interfaces/IMetadataContainer.cs b/src/Microsoft.OpenApi/Interfaces/IMetadataContainer.cs index d97635c9c..4407577df 100644 --- a/src/Microsoft.OpenApi/Interfaces/IMetadataContainer.cs +++ b/src/Microsoft.OpenApi/Interfaces/IMetadataContainer.cs @@ -3,17 +3,16 @@ using System.Collections.Generic; -namespace Microsoft.OpenApi.Interfaces +namespace Microsoft.OpenApi.Interfaces; +/// +/// Represents an Open API element that can be annotated with +/// non-serializable properties in a property bag. +/// +public interface IMetadataContainer { /// - /// Represents an Open API element that can be annotated with - /// non-serializable properties in a property bag. + /// A collection of properties associated with the current OpenAPI element to be used by the application. + /// Metadata are NOT (de)serialized with the schema and can be used for custom properties. /// - public interface IMetadataContainer - { - /// - /// A collection of properties associated with the current OpenAPI element. - /// - Dictionary? Metadata { get; set; } - } + Dictionary? Metadata { get; set; } } diff --git a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiSchema.cs b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiSchema.cs index ea6f4edd3..8ef1dec1a 100644 --- a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiSchema.cs +++ b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiSchema.cs @@ -17,6 +17,7 @@ public interface IOpenApiSchema : IOpenApiDescribedElement, IOpenApiReadOnlyExte /// public string? Title { get; } + /// /// $schema, a JSON Schema dialect identifier. Value must be a URI /// @@ -280,12 +281,6 @@ public interface IOpenApiSchema : IOpenApiDescribedElement, IOpenApiReadOnlyExte /// public Dictionary? UnrecognizedKeywords { get; } - /// - /// Any annotation to attach to the schema to be used by the application. - /// Annotations are NOT (de)serialized with the schema and can be used for custom properties. - /// - public Dictionary? Annotations { get; } - /// /// Follow JSON Schema definition:https://json-schema.org/draft/2020-12/json-schema-validation#section-6.5.4 /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiSchema.cs b/src/Microsoft.OpenApi/Models/OpenApiSchema.cs index 28c3e30c9..94d0d9299 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiSchema.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiSchema.cs @@ -18,7 +18,7 @@ namespace Microsoft.OpenApi.Models /// /// The Schema Object allows the definition of input and output data types. /// - public class OpenApiSchema : IOpenApiExtensible, IOpenApiSchema + public class OpenApiSchema : IOpenApiExtensible, IOpenApiSchema, IMetadataContainer { /// public string? Title { get; set; } @@ -248,7 +248,7 @@ public string? Minimum public Dictionary? UnrecognizedKeywords { get; set; } /// - public Dictionary? Annotations { get; set; } + public Dictionary? Metadata { get; set; } /// public Dictionary>? DependentRequired { get; set; } @@ -317,7 +317,7 @@ internal OpenApiSchema(IOpenApiSchema schema) Deprecated = schema.Deprecated; Xml = schema.Xml != null ? new(schema.Xml) : null; Extensions = schema.Extensions != null ? new Dictionary(schema.Extensions) : null; - Annotations = schema.Annotations != null ? new Dictionary(schema.Annotations) : null; + Metadata = schema is IMetadataContainer { Metadata: not null } mContainer ? new Dictionary(mContainer.Metadata) : null; UnrecognizedKeywords = schema.UnrecognizedKeywords != null ? new Dictionary(schema.UnrecognizedKeywords) : null; DependentRequired = schema.DependentRequired != null ? new Dictionary>(schema.DependentRequired) : null; } diff --git a/src/Microsoft.OpenApi/Models/References/OpenApiSchemaReference.cs b/src/Microsoft.OpenApi/Models/References/OpenApiSchemaReference.cs index 7dd3ea3e5..6c191c8e5 100644 --- a/src/Microsoft.OpenApi/Models/References/OpenApiSchemaReference.cs +++ b/src/Microsoft.OpenApi/Models/References/OpenApiSchemaReference.cs @@ -139,9 +139,6 @@ public string? Description /// public Dictionary? UnrecognizedKeywords { get => Target?.UnrecognizedKeywords; } - /// - public Dictionary? Annotations { get => Target?.Annotations; } - /// public Dictionary>? DependentRequired { get => Target?.DependentRequired; } diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs index 7b391c401..2774680a7 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs @@ -36,7 +36,7 @@ public class OpenApiDocumentTests ["property1"] = new OpenApiSchema() { Type = JsonSchemaType.String, - Annotations = new Dictionary { { "key1", "value" } } + Metadata = new Dictionary { { "key1", "value" } } } } }, @@ -55,10 +55,10 @@ public class OpenApiDocumentTests ["property1"] = new OpenApiSchema() { Type = JsonSchemaType.String, - Annotations = new Dictionary { { "key1", "value" } } + Metadata = new Dictionary { { "key1", "value" } } } }, - Annotations = new Dictionary { { "key1", "value" } }, + Metadata = new Dictionary { { "key1", "value" } }, }, ["schema2"] = new OpenApiSchema() { diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs index 6e2f00656..779a87e3e 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs @@ -38,7 +38,7 @@ public class OpenApiSchemaTests { Url = new("http://example.com/externalDocs") }, - Annotations = new Dictionary { { "key1", "value1" }, { "key2", 2 } } + Metadata = new Dictionary { { "key1", "value1" }, { "key2", 2 } } }; public static readonly OpenApiSchema AdvancedSchemaObject = new() @@ -473,24 +473,24 @@ public void OpenApiSchemaCopyConstructorSucceeds() } [Fact] - public void OpenApiSchemaCopyConstructorWithAnnotationsSucceeds() + public void OpenApiSchemaCopyConstructorWithMetadataSucceeds() { var baseSchema = new OpenApiSchema { - Annotations = new Dictionary + Metadata = new Dictionary { ["key1"] = "value1", ["key2"] = 2 } }; - var actualSchema = baseSchema.CreateShallowCopy(); + var actualSchema = Assert.IsType(baseSchema.CreateShallowCopy()); - Assert.Equal(baseSchema.Annotations["key1"], actualSchema.Annotations["key1"]); + Assert.Equal(baseSchema.Metadata["key1"], actualSchema.Metadata["key1"]); - baseSchema.Annotations["key1"] = "value2"; + baseSchema.Metadata["key1"] = "value2"; - Assert.NotEqual(baseSchema.Annotations["key1"], actualSchema.Annotations["key1"]); + Assert.NotEqual(baseSchema.Metadata["key1"], actualSchema.Metadata["key1"]); } public static TheoryData SchemaExamples() diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index 4a8fcea74..2ec1fb15b 100644 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -415,7 +415,6 @@ namespace Microsoft.OpenApi.Models.Interfaces Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema? AdditionalProperties { get; } bool AdditionalPropertiesAllowed { get; } System.Collections.Generic.List? AllOf { get; } - System.Collections.Generic.Dictionary? Annotations { get; } System.Collections.Generic.List? AnyOf { get; } string? Comment { get; } string? Const { get; } @@ -1010,13 +1009,12 @@ namespace Microsoft.OpenApi.Models public OpenApiResponses() { } public OpenApiResponses(Microsoft.OpenApi.Models.OpenApiResponses openApiResponses) { } } - public class OpenApiSchema : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema + public class OpenApiSchema : Microsoft.OpenApi.Interfaces.IMetadataContainer, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema { public OpenApiSchema() { } public Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema? AdditionalProperties { get; set; } public bool AdditionalPropertiesAllowed { get; set; } public System.Collections.Generic.List? AllOf { get; set; } - public System.Collections.Generic.Dictionary? Annotations { get; set; } public System.Collections.Generic.List? AnyOf { get; set; } public string? Comment { get; set; } public string? Const { get; set; } @@ -1042,6 +1040,7 @@ namespace Microsoft.OpenApi.Models public int? MaxLength { get; set; } public int? MaxProperties { get; set; } public string? Maximum { get; set; } + public System.Collections.Generic.Dictionary? Metadata { get; set; } public int? MinItems { get; set; } public int? MinLength { get; set; } public int? MinProperties { get; set; } @@ -1348,7 +1347,6 @@ namespace Microsoft.OpenApi.Models.References public Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema? AdditionalProperties { get; } public bool AdditionalPropertiesAllowed { get; } public System.Collections.Generic.List? AllOf { get; } - public System.Collections.Generic.Dictionary? Annotations { get; } public System.Collections.Generic.List? AnyOf { get; } public string? Comment { get; } public string? Const { get; } From 6a3b2a91b159670d92f5f50dd229df593bd80d1f Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Wed, 9 Apr 2025 16:01:42 -0400 Subject: [PATCH 060/984] chore: fixes ill defined unit test Signed-off-by: Vincent Biret --- .../OpenApiWorkspaceTests/OpenApiWorkspaceStreamTests.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/Microsoft.OpenApi.Readers.Tests/OpenApiWorkspaceTests/OpenApiWorkspaceStreamTests.cs b/test/Microsoft.OpenApi.Readers.Tests/OpenApiWorkspaceTests/OpenApiWorkspaceStreamTests.cs index 671a4a9eb..a8eb30cc3 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/OpenApiWorkspaceTests/OpenApiWorkspaceStreamTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/OpenApiWorkspaceTests/OpenApiWorkspaceStreamTests.cs @@ -104,7 +104,9 @@ public async Task LoadDocumentWithExternalReferencesInSubDirectories() Assert.Equal(JsonSchemaType.Array, petsSchema.Type); var petSchema = petsSchema.Items; - Assert.IsType(petSchema); + var petSchemaReference = Assert.IsType(petSchema); + var petSchemaTarget = petSchemaReference.RecursiveTarget; + Assert.NotNull(petSchemaTarget); Assert.Equivalent(new OpenApiSchema { @@ -125,7 +127,7 @@ public async Task LoadDocumentWithExternalReferencesInSubDirectories() Type = JsonSchemaType.String } } - }, petSchema); + }, petSchemaTarget); } } From 6d249bc755613bedcdeb656905f23c317f93c19d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 9 Apr 2025 22:04:40 +0000 Subject: [PATCH 061/984] chore(deps): bump Microsoft.Extensions.Logging, Microsoft.Extensions.Logging.Abstractions, Microsoft.Extensions.Logging.Console and System.Text.Json Bumps [Microsoft.Extensions.Logging](https://github.com/dotnet/runtime), [Microsoft.Extensions.Logging.Abstractions](https://github.com/dotnet/runtime), [Microsoft.Extensions.Logging.Console](https://github.com/dotnet/runtime) and [System.Text.Json](https://github.com/dotnet/runtime). These dependencies needed to be updated together. Updates `Microsoft.Extensions.Logging` from 9.0.3 to 9.0.4 - [Release notes](https://github.com/dotnet/runtime/releases) - [Commits](https://github.com/dotnet/runtime/compare/v9.0.3...v9.0.4) Updates `Microsoft.Extensions.Logging.Abstractions` from 9.0.4 to 9.0.4 - [Release notes](https://github.com/dotnet/runtime/releases) - [Commits](https://github.com/dotnet/runtime/compare/v9.0.4...v9.0.4) Updates `Microsoft.Extensions.Logging.Console` from 9.0.3 to 9.0.4 - [Release notes](https://github.com/dotnet/runtime/releases) - [Commits](https://github.com/dotnet/runtime/compare/v9.0.3...v9.0.4) Updates `System.Text.Json` from 9.0.4 to 9.0.4 - [Release notes](https://github.com/dotnet/runtime/releases) - [Commits](https://github.com/dotnet/runtime/compare/v9.0.4...v9.0.4) --- updated-dependencies: - dependency-name: Microsoft.Extensions.Logging dependency-version: 9.0.4 dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: Microsoft.Extensions.Logging.Abstractions dependency-version: 9.0.4 dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: Microsoft.Extensions.Logging.Console dependency-version: 9.0.4 dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: System.Text.Json dependency-version: 9.0.4 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index 437fbef5d..1e1a8c803 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -28,9 +28,9 @@ - + - + runtime; build; native; contentfiles; analyzers; buildtransitive From 63a8a3480b20809367c2dc7616e23be87a51f8fe Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Fri, 11 Apr 2025 05:02:56 -0400 Subject: [PATCH 062/984] ci/performance testing (#2304) * ci: performance project scaffolding * chore: moves benchmark to dedicated directory * chore: commits initial benchmark results * ci: adds a comparison project for benchmark results * ci: adds benchmark runs and comparison * ci: renames empty models tests * chore: refactors to a command structure * chore: moves models to a dedicated source file * chore: uses STJ attribute based serialization * ci: fixes missing project argument * ci: fixes reports path * chore: moves policies to own directory * chore: no warn on static method for perf test project * chore: linting * chore: reduces run time for empty performance tests * chore: linting * fix: a bug where the input stream would be disposed not matter what * ci: fixes working directory for benchmark run * ci: adds basic infrastructure for descriptions based performance tests * chore: refresh empty object tests * ci: adds comparison run for descriptions comparisons * ci: adds percentage based comparisons * ci: adds large description to performance tests * ci: adds yaml descriptions perf tests to compare * ci: adds truncation in percentage difference to reduce noise --------- Signed-off-by: Vincent Biret --- .github/workflows/ci-cd.yml | 39 ++- .vscode/launch.json | 31 ++ .vscode/tasks.json | 2 +- Microsoft.OpenApi.sln | 15 + .../performance.Descriptions-report-github.md | 18 ++ .../performance.Descriptions-report.csv | 5 + .../performance.Descriptions-report.html | 35 ++ .../performance.Descriptions-report.json | 1 + .../performance.EmptyModels-report-github.md | 42 +++ .../performance.EmptyModels-report.csv | 29 ++ .../performance.EmptyModels-report.html | 59 ++++ .../performance.EmptyModels-report.json | 1 + performance/benchmark/Descriptions.cs | 97 ++++++ performance/benchmark/EmptyModels.cs | 153 +++++++++ performance/benchmark/PerformanceTests.csproj | 28 ++ performance/benchmark/Program.cs | 13 + performance/resultsComparer/Logger.cs | 26 ++ performance/resultsComparer/Program.cs | 47 +++ .../handlers/AsyncCommandHandler.cs | 14 + .../handlers/CompareCommandHandler.cs | 96 ++++++ .../resultsComparer/models/BenchmarkReport.cs | 21 ++ .../policies/BaseBenchmarkComparisonPolicy.cs | 17 + .../policies/IBenchmarkComparisonPolicy.cs | 40 +++ .../policies/IdenticalMemoryUsagePolicy.cs | 17 + .../policies/PercentageMemoryUsagePolicy.cs | 73 +++++ .../resultsComparer/resultsComparer.csproj | 19 ++ .../Reader/OpenApiModelFactory.cs | 27 +- .../Samples/OpenApiDocument/petStore.json | 298 ++++++++++++++++++ 28 files changed, 1248 insertions(+), 15 deletions(-) create mode 100644 performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.Descriptions-report-github.md create mode 100644 performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.Descriptions-report.csv create mode 100644 performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.Descriptions-report.html create mode 100644 performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.Descriptions-report.json create mode 100644 performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.EmptyModels-report-github.md create mode 100644 performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.EmptyModels-report.csv create mode 100644 performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.EmptyModels-report.html create mode 100644 performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.EmptyModels-report.json create mode 100644 performance/benchmark/Descriptions.cs create mode 100644 performance/benchmark/EmptyModels.cs create mode 100644 performance/benchmark/PerformanceTests.csproj create mode 100644 performance/benchmark/Program.cs create mode 100644 performance/resultsComparer/Logger.cs create mode 100644 performance/resultsComparer/Program.cs create mode 100644 performance/resultsComparer/handlers/AsyncCommandHandler.cs create mode 100644 performance/resultsComparer/handlers/CompareCommandHandler.cs create mode 100644 performance/resultsComparer/models/BenchmarkReport.cs create mode 100644 performance/resultsComparer/policies/BaseBenchmarkComparisonPolicy.cs create mode 100644 performance/resultsComparer/policies/IBenchmarkComparisonPolicy.cs create mode 100644 performance/resultsComparer/policies/IdenticalMemoryUsagePolicy.cs create mode 100644 performance/resultsComparer/policies/PercentageMemoryUsagePolicy.cs create mode 100644 performance/resultsComparer/resultsComparer.csproj create mode 100644 test/Microsoft.OpenApi.Readers.Tests/V3Tests/Samples/OpenApiDocument/petStore.json diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 2ddce58b7..595d473c8 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -16,7 +16,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v4 with: - dotnet-version: 8.0.x + dotnet-version: 8.x - name: Checkout repository id: checkout_repo @@ -51,3 +51,40 @@ jobs: - name: Validate Trimming warnings run: dotnet publish -c Release -r win-x64 /p:TreatWarningsAsErrors=true /warnaserror -f net8.0 working-directory: ./test/Microsoft.OpenApi.Trimming.Tests + + validate-performance: + name: Validate performance of the library + runs-on: ubuntu-latest + needs: [ci] + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.x + + - name: Copy committed results + run: | + mkdir -p ./performanceResults + cp -r ./performance/benchmark/BenchmarkDotNet.Artifacts/results/* ./performanceResults + + - name: Run performance tests + run: | + dotnet run -c Release + working-directory: ./performance/benchmark + + - name: Run comparison tool for empty models + run: dotnet run -c Release --project ./performance/resultsComparer/resultsComparer.csproj -- compare $OLD_REPORT $NEW_REPORT -p IdenticalMemoryUsage + shell: bash + env: + NEW_REPORT: "${{ github.workspace }}/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.EmptyModels-report.json" + OLD_REPORT: "${{ github.workspace }}/performanceResults/performance.EmptyModels-report.json" + + - name: Run comparison tool for descriptions + run: dotnet run -c Release --project ./performance/resultsComparer/resultsComparer.csproj -- compare $OLD_REPORT $NEW_REPORT -p ZeroPointTwoPercentDifferenceMemoryUsage + shell: bash + env: + NEW_REPORT: "${{ github.workspace }}/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.Descriptions-report.json" + OLD_REPORT: "${{ github.workspace }}/performanceResults/performance.Descriptions-report.json" diff --git a/.vscode/launch.json b/.vscode/launch.json index 1ff544a39..66912fac4 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -19,6 +19,37 @@ "console": "internalConsole", "stopAtEntry": false }, + { + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/main/debugger-launchjson.md + "name": "Launch Benchmark", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceFolder}/performance/benchmark/bin/Release/net8.0/PerformanceTests.dll", + // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console + "console": "internalConsole", + "stopAtEntry": false, + }, + { + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/main/debugger-launchjson.md + "name": "Launch Results comparer", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceFolder}/performance/resultsComparer/bin/Debug/net8.0/resultsComparer.dll", + "cwd": "${workspaceFolder}/performance/resultsComparer", + "args": ["compare"], + // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console + "console": "internalConsole", + "stopAtEntry": false, + "requireExactSource": false, + }, { // Use IntelliSense to find out which attributes exist for C# debugging // Use hover for the description of the existing attributes diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 6040a610f..d2bd5722f 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -10,7 +10,7 @@ "group": "build", "args": [ "build", - "${workspaceFolder}/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj", + "${workspaceFolder}/Microsoft.OpenApi.sln", "/property:GenerateFullPaths=true", "/consoleloggerparameters:NoSummary" ], diff --git a/Microsoft.OpenApi.sln b/Microsoft.OpenApi.sln index b1444995a..b91029eca 100644 --- a/Microsoft.OpenApi.sln +++ b/Microsoft.OpenApi.sln @@ -30,6 +30,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.OpenApi.Hidi", "s EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.OpenApi.Hidi.Tests", "test\Microsoft.OpenApi.Hidi.Tests\Microsoft.OpenApi.Hidi.Tests.csproj", "{6ADC5D41-EDD2-4206-B815-5DFF739C6832}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PerformanceTests", "performance\benchmark\PerformanceTests.csproj", "{537E49E3-325E-40EE-A90E-7556D4D333AA}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "performance", "performance", "{4BB7E3F7-CA7E-45D3-B5AC-5DBB510FD528}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "resultsComparer", "performance\resultsComparer\resultsComparer.csproj", "{5EEA836B-3E08-4BE1-82B8-5236D031B497}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -68,6 +74,14 @@ Global {6ADC5D41-EDD2-4206-B815-5DFF739C6832}.Debug|Any CPU.Build.0 = Debug|Any CPU {6ADC5D41-EDD2-4206-B815-5DFF739C6832}.Release|Any CPU.ActiveCfg = Release|Any CPU {6ADC5D41-EDD2-4206-B815-5DFF739C6832}.Release|Any CPU.Build.0 = Release|Any CPU + {537E49E3-325E-40EE-A90E-7556D4D333AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {537E49E3-325E-40EE-A90E-7556D4D333AA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {537E49E3-325E-40EE-A90E-7556D4D333AA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {537E49E3-325E-40EE-A90E-7556D4D333AA}.Release|Any CPU.Build.0 = Release|Any CPU + {5EEA836B-3E08-4BE1-82B8-5236D031B497}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5EEA836B-3E08-4BE1-82B8-5236D031B497}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5EEA836B-3E08-4BE1-82B8-5236D031B497}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5EEA836B-3E08-4BE1-82B8-5236D031B497}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -81,6 +95,7 @@ Global {1D2E0C6E-B103-4CB6-912E-D56FA1501296} = {6357D7FD-2DE4-4900-ADB9-ABC37052040A} {538936B4-5E14-4EA3-9FD0-F43E2DD014FB} = {E546B92F-20A8-49C3-8323-4B25BB78F3E1} {6ADC5D41-EDD2-4206-B815-5DFF739C6832} = {6357D7FD-2DE4-4900-ADB9-ABC37052040A} + {5EEA836B-3E08-4BE1-82B8-5236D031B497} = {4BB7E3F7-CA7E-45D3-B5AC-5DBB510FD528} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {9F171EFC-0DB5-4B10-ABFA-AF48D52CC565} diff --git a/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.Descriptions-report-github.md b/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.Descriptions-report-github.md new file mode 100644 index 000000000..e1ca8eed6 --- /dev/null +++ b/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.Descriptions-report-github.md @@ -0,0 +1,18 @@ +``` + +BenchmarkDotNet v0.14.0, Windows 11 (10.0.26100.3476) +11th Gen Intel Core i7-1185G7 3.00GHz, 1 CPU, 8 logical and 4 physical cores +.NET SDK 8.0.408 + [Host] : .NET 8.0.15 (8.0.1525.16413), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI + ShortRun : .NET 8.0.15 (8.0.1525.16413), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI + +Job=ShortRun IterationCount=3 LaunchCount=1 +WarmupCount=3 + +``` +| Method | Mean | Error | StdDev | Gen0 | Gen1 | Gen2 | Allocated | +|------------- |-------------:|--------------:|-------------:|-----------:|-----------:|----------:|-------------:| +| PetStoreYaml | 450.5 μs | 59.26 μs | 3.25 μs | 58.5938 | 11.7188 | - | 377.15 KB | +| PetStoreJson | 172.8 μs | 123.46 μs | 6.77 μs | 39.0625 | 7.8125 | - | 239.29 KB | +| GHESYaml | 943,452.7 μs | 137,685.49 μs | 7,547.01 μs | 66000.0000 | 21000.0000 | 3000.0000 | 389463.91 KB | +| GHESJson | 468,401.8 μs | 300,711.80 μs | 16,483.03 μs | 41000.0000 | 15000.0000 | 3000.0000 | 250934.62 KB | diff --git a/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.Descriptions-report.csv b/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.Descriptions-report.csv new file mode 100644 index 000000000..ff86e86e7 --- /dev/null +++ b/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.Descriptions-report.csv @@ -0,0 +1,5 @@ +Method,Job,AnalyzeLaunchVariance,EvaluateOverhead,MaxAbsoluteError,MaxRelativeError,MinInvokeCount,MinIterationTime,OutlierMode,Affinity,EnvironmentVariables,Jit,LargeAddressAware,Platform,PowerPlanMode,Runtime,AllowVeryLargeObjects,Concurrent,CpuGroups,Force,HeapAffinitizeMask,HeapCount,NoAffinitize,RetainVm,Server,Arguments,BuildConfiguration,Clock,EngineFactory,NuGetReferences,Toolchain,IsMutator,InvocationCount,IterationCount,IterationTime,LaunchCount,MaxIterationCount,MaxWarmupIterationCount,MemoryRandomization,MinIterationCount,MinWarmupIterationCount,RunStrategy,UnrollFactor,WarmupCount,Mean,Error,StdDev,Gen0,Gen1,Gen2,Allocated +PetStoreYaml,ShortRun,False,Default,Default,Default,Default,Default,Default,11111111,Empty,RyuJit,Default,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,450.5 μs,59.26 μs,3.25 μs,58.5938,11.7188,0.0000,377.15 KB +PetStoreJson,ShortRun,False,Default,Default,Default,Default,Default,Default,11111111,Empty,RyuJit,Default,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,172.8 μs,123.46 μs,6.77 μs,39.0625,7.8125,0.0000,239.29 KB +GHESYaml,ShortRun,False,Default,Default,Default,Default,Default,Default,11111111,Empty,RyuJit,Default,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,"943,452.7 μs","137,685.49 μs","7,547.01 μs",66000.0000,21000.0000,3000.0000,389463.91 KB +GHESJson,ShortRun,False,Default,Default,Default,Default,Default,Default,11111111,Empty,RyuJit,Default,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,"468,401.8 μs","300,711.80 μs","16,483.03 μs",41000.0000,15000.0000,3000.0000,250934.62 KB diff --git a/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.Descriptions-report.html b/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.Descriptions-report.html new file mode 100644 index 000000000..497e2dda7 --- /dev/null +++ b/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.Descriptions-report.html @@ -0,0 +1,35 @@ + + + + +performance.Descriptions-20250409-150544 + + + + +

+BenchmarkDotNet v0.14.0, Windows 11 (10.0.26100.3476)
+11th Gen Intel Core i7-1185G7 3.00GHz, 1 CPU, 8 logical and 4 physical cores
+.NET SDK 8.0.408
+  [Host]   : .NET 8.0.15 (8.0.1525.16413), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI
+  ShortRun : .NET 8.0.15 (8.0.1525.16413), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI
+
+
Job=ShortRun  IterationCount=3  LaunchCount=1  
+WarmupCount=3  
+
+ + + + + + + + +
MethodMean Error StdDevGen0Gen1Gen2Allocated
PetStoreYaml450.5 μs59.26 μs3.25 μs58.593811.7188-377.15 KB
PetStoreJson172.8 μs123.46 μs6.77 μs39.06257.8125-239.29 KB
GHESYaml943,452.7 μs137,685.49 μs7,547.01 μs66000.000021000.00003000.0000389463.91 KB
GHESJson468,401.8 μs300,711.80 μs16,483.03 μs41000.000015000.00003000.0000250934.62 KB
+ + diff --git a/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.Descriptions-report.json b/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.Descriptions-report.json new file mode 100644 index 000000000..4e2ae4c76 --- /dev/null +++ b/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.Descriptions-report.json @@ -0,0 +1 @@ +{"Title":"performance.Descriptions-20250409-150544","HostEnvironmentInfo":{"BenchmarkDotNetCaption":"BenchmarkDotNet","BenchmarkDotNetVersion":"0.14.0","OsVersion":"Windows 11 (10.0.26100.3476)","ProcessorName":"11th Gen Intel Core i7-1185G7 3.00GHz","PhysicalProcessorCount":1,"PhysicalCoreCount":4,"LogicalCoreCount":8,"RuntimeVersion":".NET 8.0.15 (8.0.1525.16413)","Architecture":"X64","HasAttachedDebugger":false,"HasRyuJit":true,"Configuration":"RELEASE","DotNetCliVersion":"8.0.408","ChronometerFrequency":{"Hertz":10000000},"HardwareTimerKind":"Unknown"},"Benchmarks":[{"DisplayInfo":"Descriptions.PetStoreYaml: ShortRun(IterationCount=3, LaunchCount=1, WarmupCount=3)","Namespace":"performance","Type":"Descriptions","Method":"PetStoreYaml","MethodTitle":"PetStoreYaml","Parameters":"","FullName":"performance.Descriptions.PetStoreYaml","HardwareIntrinsics":"AVX-512F+CD+BW+DQ+VL+VBMI,AES,BMI1,BMI2,FMA,LZCNT,PCLMUL,POPCNT VectorSize=256","Statistics":{"OriginalValues":[447637.109375,449741.015625,454012.109375],"N":3,"Min":447637.109375,"LowerFence":443907.8125,"Q1":448689.0625,"Median":449741.015625,"Mean":450463.4114583333,"Q3":451876.5625,"UpperFence":456657.8125,"Max":454012.109375,"InterquartileRange":3187.5,"LowerOutliers":[],"UpperOutliers":[],"AllOutliers":[],"StandardError":1875.4153366666117,"Variance":10551548.05501302,"StandardDeviation":3248.3146484004624,"Skewness":0.21139201124486484,"Kurtosis":0.666666666666672,"ConfidenceInterval":{"N":3,"Mean":450463.4114583333,"StandardError":1875.4153366666117,"Level":12,"Margin":59261.351337014705,"Lower":391202.0601213186,"Upper":509724.762795348},"Percentiles":{"P0":447637.109375,"P25":448689.0625,"P50":449741.015625,"P67":451193.1875,"P80":452303.671875,"P85":452730.78125,"P90":453157.890625,"P95":453585,"P100":454012.109375}},"Memory":{"Gen0Collections":15,"Gen1Collections":3,"Gen2Collections":0,"TotalOperations":256,"BytesAllocatedPerOperation":386204},"Measurements":[{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":394500},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":85865700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":1,"Operations":2,"Nanoseconds":4305100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":2,"Operations":3,"Nanoseconds":5885300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":3,"Operations":4,"Nanoseconds":7927600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":4,"Operations":5,"Nanoseconds":10518000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":5,"Operations":6,"Nanoseconds":13963300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":6,"Operations":7,"Nanoseconds":15788400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":7,"Operations":8,"Nanoseconds":19028600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":8,"Operations":9,"Nanoseconds":23123500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":9,"Operations":10,"Nanoseconds":21872700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":10,"Operations":11,"Nanoseconds":26173500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":11,"Operations":12,"Nanoseconds":35665500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":12,"Operations":13,"Nanoseconds":33094500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":13,"Operations":14,"Nanoseconds":31872000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":14,"Operations":15,"Nanoseconds":32073900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":15,"Operations":16,"Nanoseconds":37137400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":16,"Operations":32,"Nanoseconds":71579000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":17,"Operations":64,"Nanoseconds":144341200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":18,"Operations":128,"Nanoseconds":289690000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":19,"Operations":256,"Nanoseconds":635578200},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":256,"Nanoseconds":182854400},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":256,"Nanoseconds":152507400},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":256,"Nanoseconds":125976300},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":256,"Nanoseconds":114595100},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":256,"Nanoseconds":115133700},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":256,"Nanoseconds":116227100},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":1,"Operations":256,"Nanoseconds":114595100},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":2,"Operations":256,"Nanoseconds":115133700},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":3,"Operations":256,"Nanoseconds":116227100}],"Metrics":[{"Value":58.59375,"Descriptor":{"Id":"Gen0Collects","DisplayName":"Gen0","Legend":"GC Generation 0 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":0}},{"Value":11.71875,"Descriptor":{"Id":"Gen1Collects","DisplayName":"Gen1","Legend":"GC Generation 1 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":1}},{"Value":0,"Descriptor":{"Id":"Gen2Collects","DisplayName":"Gen2","Legend":"GC Generation 2 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":2}},{"Value":386204,"Descriptor":{"Id":"Allocated Memory","DisplayName":"Allocated","Legend":"Allocated memory per single operation (managed only, inclusive, 1KB = 1024B)","NumberFormat":"0.##","UnitType":2,"Unit":"B","TheGreaterTheBetter":false,"PriorityInCategory":3}}]},{"DisplayInfo":"Descriptions.PetStoreJson: ShortRun(IterationCount=3, LaunchCount=1, WarmupCount=3)","Namespace":"performance","Type":"Descriptions","Method":"PetStoreJson","MethodTitle":"PetStoreJson","Parameters":"","FullName":"performance.Descriptions.PetStoreJson","HardwareIntrinsics":"AVX-512F+CD+BW+DQ+VL+VBMI,AES,BMI1,BMI2,FMA,LZCNT,PCLMUL,POPCNT VectorSize=256","Statistics":{"OriginalValues":[169736.9140625,168194.23828125,180609.9609375],"N":3,"Min":168194.23828125,"LowerFence":159653.7841796875,"Q1":168965.576171875,"Median":169736.9140625,"Mean":172847.03776041666,"Q3":175173.4375,"UpperFence":184485.2294921875,"Max":180609.9609375,"InterquartileRange":6207.861328125,"LowerOutliers":[],"UpperOutliers":[],"AllOutliers":[],"StandardError":3906.9252331164903,"Variance":45792194.33148702,"StandardDeviation":6766.993005130641,"Skewness":0.36251844154250606,"Kurtosis":0.6666666666666686,"ConfidenceInterval":{"N":3,"Mean":172847.03776041666,"StandardError":3906.9252331164903,"Level":12,"Margin":123455.1431677467,"Lower":49391.89459266995,"Upper":296302.18092816335},"Percentiles":{"P0":168194.23828125,"P25":168965.576171875,"P50":169736.9140625,"P67":173433.75,"P80":176260.7421875,"P85":177348.046875,"P90":178435.3515625,"P95":179522.65625,"P100":180609.9609375}},"Memory":{"Gen0Collections":40,"Gen1Collections":8,"Gen2Collections":0,"TotalOperations":1024,"BytesAllocatedPerOperation":245033},"Measurements":[{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":392600},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":71597700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":1,"Operations":2,"Nanoseconds":2079600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":2,"Operations":3,"Nanoseconds":3030600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":3,"Operations":4,"Nanoseconds":3181300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":4,"Operations":5,"Nanoseconds":5170200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":5,"Operations":6,"Nanoseconds":5197400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":6,"Operations":7,"Nanoseconds":7488600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":7,"Operations":8,"Nanoseconds":5557300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":8,"Operations":9,"Nanoseconds":8967300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":9,"Operations":10,"Nanoseconds":8197200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":10,"Operations":11,"Nanoseconds":9306000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":11,"Operations":12,"Nanoseconds":12349000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":12,"Operations":13,"Nanoseconds":13060000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":13,"Operations":14,"Nanoseconds":15590900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":14,"Operations":15,"Nanoseconds":12075700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":15,"Operations":16,"Nanoseconds":12788400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":16,"Operations":32,"Nanoseconds":28598600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":17,"Operations":64,"Nanoseconds":51112700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":18,"Operations":128,"Nanoseconds":76196700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":19,"Operations":256,"Nanoseconds":166161000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":20,"Operations":512,"Nanoseconds":354228100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":21,"Operations":1024,"Nanoseconds":585351700},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":1024,"Nanoseconds":270282600},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":1024,"Nanoseconds":201527300},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":1024,"Nanoseconds":178464500},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":1024,"Nanoseconds":173810600},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":1024,"Nanoseconds":172230900},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":1024,"Nanoseconds":184944600},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":1,"Operations":1024,"Nanoseconds":173810600},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":2,"Operations":1024,"Nanoseconds":172230900},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":3,"Operations":1024,"Nanoseconds":184944600}],"Metrics":[{"Value":39.0625,"Descriptor":{"Id":"Gen0Collects","DisplayName":"Gen0","Legend":"GC Generation 0 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":0}},{"Value":7.8125,"Descriptor":{"Id":"Gen1Collects","DisplayName":"Gen1","Legend":"GC Generation 1 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":1}},{"Value":0,"Descriptor":{"Id":"Gen2Collects","DisplayName":"Gen2","Legend":"GC Generation 2 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":2}},{"Value":245033,"Descriptor":{"Id":"Allocated Memory","DisplayName":"Allocated","Legend":"Allocated memory per single operation (managed only, inclusive, 1KB = 1024B)","NumberFormat":"0.##","UnitType":2,"Unit":"B","TheGreaterTheBetter":false,"PriorityInCategory":3}}]},{"DisplayInfo":"Descriptions.GHESYaml: ShortRun(IterationCount=3, LaunchCount=1, WarmupCount=3)","Namespace":"performance","Type":"Descriptions","Method":"GHESYaml","MethodTitle":"GHESYaml","Parameters":"","FullName":"performance.Descriptions.GHESYaml","HardwareIntrinsics":"AVX-512F+CD+BW+DQ+VL+VBMI,AES,BMI1,BMI2,FMA,LZCNT,PCLMUL,POPCNT VectorSize=256","Statistics":{"OriginalValues":[941728100,936917200,951712700],"N":3,"Min":936917200,"LowerFence":928226025,"Q1":939322650,"Median":941728100,"Mean":943452666.6666666,"Q3":946720400,"UpperFence":957817025,"Max":951712700,"InterquartileRange":7397750,"LowerOutliers":[],"UpperOutliers":[],"AllOutliers":[],"StandardError":4357266.065754739,"Variance":56957302703333.336,"StandardDeviation":7547006.20798296,"Skewness":0.21657796551340572,"Kurtosis":0.6666666666666711,"ConfidenceInterval":{"N":3,"Mean":943452666.6666666,"StandardError":4357266.065754739,"Level":12,"Margin":137685487.6586978,"Lower":805767179.0079688,"Upper":1081138154.3253644},"Percentiles":{"P0":936917200,"P25":939322650,"P50":941728100,"P67":945122864,"P80":947718860,"P85":948717320,"P90":949715780,"P95":950714240,"P100":951712700}},"Memory":{"Gen0Collections":66,"Gen1Collections":21,"Gen2Collections":3,"TotalOperations":1,"BytesAllocatedPerOperation":398811040},"Measurements":[{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":202900},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":1587135300},{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":1,"Nanoseconds":1100},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":1,"Nanoseconds":1131748800},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":970653600},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":1,"Nanoseconds":938292000},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":1,"Nanoseconds":962451500},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":941728100},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":1,"Nanoseconds":936917200},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":1,"Nanoseconds":951712700},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":941728100},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":2,"Operations":1,"Nanoseconds":936917200},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":3,"Operations":1,"Nanoseconds":951712700}],"Metrics":[{"Value":66000,"Descriptor":{"Id":"Gen0Collects","DisplayName":"Gen0","Legend":"GC Generation 0 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":0}},{"Value":21000,"Descriptor":{"Id":"Gen1Collects","DisplayName":"Gen1","Legend":"GC Generation 1 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":1}},{"Value":3000,"Descriptor":{"Id":"Gen2Collects","DisplayName":"Gen2","Legend":"GC Generation 2 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":2}},{"Value":398811040,"Descriptor":{"Id":"Allocated Memory","DisplayName":"Allocated","Legend":"Allocated memory per single operation (managed only, inclusive, 1KB = 1024B)","NumberFormat":"0.##","UnitType":2,"Unit":"B","TheGreaterTheBetter":false,"PriorityInCategory":3}}]},{"DisplayInfo":"Descriptions.GHESJson: ShortRun(IterationCount=3, LaunchCount=1, WarmupCount=3)","Namespace":"performance","Type":"Descriptions","Method":"GHESJson","MethodTitle":"GHESJson","Parameters":"","FullName":"performance.Descriptions.GHESJson","HardwareIntrinsics":"AVX-512F+CD+BW+DQ+VL+VBMI,AES,BMI1,BMI2,FMA,LZCNT,PCLMUL,POPCNT VectorSize=256","Statistics":{"OriginalValues":[475136500,480451100,449617800],"N":3,"Min":449617800,"LowerFence":439252175,"Q1":462377150,"Median":475136500,"Mean":468401800,"Q3":477793800,"UpperFence":500918775,"Max":480451100,"InterquartileRange":15416650,"LowerOutliers":[],"UpperOutliers":[],"AllOutliers":[],"StandardError":9516481.059894636,"Variance":271690235290000,"StandardDeviation":16483028.70500443,"Skewness":-0.3403745708962043,"Kurtosis":0.6666666666666667,"ConfidenceInterval":{"N":3,"Mean":468401800,"StandardError":9516481.059894636,"Level":12,"Margin":300711803.170412,"Lower":167689996.829588,"Upper":769113603.1704121},"Percentiles":{"P0":449617800,"P25":462377150,"P50":475136500,"P67":476943464,"P80":478325260,"P85":478856720,"P90":479388180,"P95":479919640,"P100":480451100}},"Memory":{"Gen0Collections":41,"Gen1Collections":15,"Gen2Collections":3,"TotalOperations":1,"BytesAllocatedPerOperation":256957048},"Measurements":[{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":242900},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":909021600},{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":1,"Nanoseconds":700},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":1,"Nanoseconds":690585100},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":540333400},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":1,"Nanoseconds":493766000},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":1,"Nanoseconds":466957700},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":475136500},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":1,"Nanoseconds":480451100},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":1,"Nanoseconds":449617800},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":475136500},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":2,"Operations":1,"Nanoseconds":480451100},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":3,"Operations":1,"Nanoseconds":449617800}],"Metrics":[{"Value":41000,"Descriptor":{"Id":"Gen0Collects","DisplayName":"Gen0","Legend":"GC Generation 0 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":0}},{"Value":15000,"Descriptor":{"Id":"Gen1Collects","DisplayName":"Gen1","Legend":"GC Generation 1 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":1}},{"Value":3000,"Descriptor":{"Id":"Gen2Collects","DisplayName":"Gen2","Legend":"GC Generation 2 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":2}},{"Value":256957048,"Descriptor":{"Id":"Allocated Memory","DisplayName":"Allocated","Legend":"Allocated memory per single operation (managed only, inclusive, 1KB = 1024B)","NumberFormat":"0.##","UnitType":2,"Unit":"B","TheGreaterTheBetter":false,"PriorityInCategory":3}}]}]} diff --git a/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.EmptyModels-report-github.md b/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.EmptyModels-report-github.md new file mode 100644 index 000000000..65cfa719a --- /dev/null +++ b/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.EmptyModels-report-github.md @@ -0,0 +1,42 @@ +``` + +BenchmarkDotNet v0.14.0, Windows 11 (10.0.26100.3476) +11th Gen Intel Core i7-1185G7 3.00GHz, 1 CPU, 8 logical and 4 physical cores +.NET SDK 8.0.408 + [Host] : .NET 8.0.15 (8.0.1525.16413), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI + ShortRun : .NET 8.0.15 (8.0.1525.16413), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI + +Job=ShortRun IterationCount=3 LaunchCount=1 +WarmupCount=3 + +``` +| Method | Mean | Error | StdDev | Gen0 | Gen1 | Allocated | +|---------------------------- |-----------:|------------:|-----------:|-------:|-------:|----------:| +| EmptyApiCallback | 4.557 ns | 2.2807 ns | 0.1250 ns | 0.0051 | - | 32 B | +| EmptyApiComponents | 5.116 ns | 0.6915 ns | 0.0379 ns | 0.0166 | - | 104 B | +| EmptyApiContact | 3.759 ns | 3.1240 ns | 0.1712 ns | 0.0076 | - | 48 B | +| EmptyApiDiscriminator | 3.442 ns | 2.3747 ns | 0.1302 ns | 0.0064 | - | 40 B | +| EmptyDocument | 397.830 ns | 46.9921 ns | 2.5758 ns | 0.1807 | 0.0005 | 1136 B | +| EmptyApiEncoding | 3.879 ns | 3.0270 ns | 0.1659 ns | 0.0089 | - | 56 B | +| EmptyApiExample | 4.045 ns | 6.0543 ns | 0.3319 ns | 0.0089 | - | 56 B | +| EmptyApiExternalDocs | 3.455 ns | 2.1233 ns | 0.1164 ns | 0.0064 | - | 40 B | +| EmptyApiHeader | 4.633 ns | 3.8933 ns | 0.2134 ns | 0.0127 | - | 80 B | +| EmptyApiInfo | 4.462 ns | 4.0279 ns | 0.2208 ns | 0.0127 | - | 80 B | +| EmptyApiLicense | 3.670 ns | 1.6839 ns | 0.0923 ns | 0.0076 | - | 48 B | +| EmptyApiLink | 4.388 ns | 1.9826 ns | 0.1087 ns | 0.0115 | - | 72 B | +| EmptyApiMediaType | 3.857 ns | 1.4731 ns | 0.0807 ns | 0.0089 | - | 56 B | +| EmptyApiOAuthFlow | 3.810 ns | 1.1359 ns | 0.0623 ns | 0.0089 | - | 56 B | +| EmptyApiOAuthFlows | 3.979 ns | 5.5181 ns | 0.3025 ns | 0.0089 | - | 56 B | +| EmptyApiOperation | 72.530 ns | 230.3314 ns | 12.6252 ns | 0.0599 | 0.0001 | 376 B | +| EmptyApiParameter | 4.919 ns | 3.2142 ns | 0.1762 ns | 0.0153 | - | 96 B | +| EmptyApiPathItem | 3.966 ns | 0.7140 ns | 0.0391 ns | 0.0102 | - | 64 B | +| EmptyApiPaths | 56.222 ns | 32.3248 ns | 1.7718 ns | 0.0395 | - | 248 B | +| EmptyApiRequestBody | 3.683 ns | 2.3246 ns | 0.1274 ns | 0.0076 | - | 48 B | +| EmptyApiResponse | 3.864 ns | 0.9334 ns | 0.0512 ns | 0.0089 | - | 56 B | +| EmptyApiResponses | 49.325 ns | 7.2131 ns | 0.3954 ns | 0.0395 | - | 248 B | +| EmptyApiSchema | 12.565 ns | 2.0834 ns | 0.1142 ns | 0.0650 | - | 408 B | +| EmptyApiSecurityRequirement | 8.411 ns | 1.5393 ns | 0.0844 ns | 0.0166 | - | 104 B | +| EmptyApiSecurityScheme | 4.719 ns | 3.8028 ns | 0.2084 ns | 0.0140 | - | 88 B | +| EmptyApiServer | 3.626 ns | 0.4928 ns | 0.0270 ns | 0.0076 | - | 48 B | +| EmptyApiServerVariable | 3.589 ns | 0.2983 ns | 0.0164 ns | 0.0076 | - | 48 B | +| EmptyApiTag | 3.889 ns | 7.4113 ns | 0.4062 ns | 0.0076 | - | 48 B | diff --git a/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.EmptyModels-report.csv b/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.EmptyModels-report.csv new file mode 100644 index 000000000..1c8fe8427 --- /dev/null +++ b/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.EmptyModels-report.csv @@ -0,0 +1,29 @@ +Method,Job,AnalyzeLaunchVariance,EvaluateOverhead,MaxAbsoluteError,MaxRelativeError,MinInvokeCount,MinIterationTime,OutlierMode,Affinity,EnvironmentVariables,Jit,LargeAddressAware,Platform,PowerPlanMode,Runtime,AllowVeryLargeObjects,Concurrent,CpuGroups,Force,HeapAffinitizeMask,HeapCount,NoAffinitize,RetainVm,Server,Arguments,BuildConfiguration,Clock,EngineFactory,NuGetReferences,Toolchain,IsMutator,InvocationCount,IterationCount,IterationTime,LaunchCount,MaxIterationCount,MaxWarmupIterationCount,MemoryRandomization,MinIterationCount,MinWarmupIterationCount,RunStrategy,UnrollFactor,WarmupCount,Mean,Error,StdDev,Gen0,Gen1,Allocated +EmptyApiCallback,ShortRun,False,Default,Default,Default,Default,Default,Default,11111111,Empty,RyuJit,Default,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,4.557 ns,2.2807 ns,0.1250 ns,0.0051,0.0000,32 B +EmptyApiComponents,ShortRun,False,Default,Default,Default,Default,Default,Default,11111111,Empty,RyuJit,Default,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,5.116 ns,0.6915 ns,0.0379 ns,0.0166,0.0000,104 B +EmptyApiContact,ShortRun,False,Default,Default,Default,Default,Default,Default,11111111,Empty,RyuJit,Default,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,3.759 ns,3.1240 ns,0.1712 ns,0.0076,0.0000,48 B +EmptyApiDiscriminator,ShortRun,False,Default,Default,Default,Default,Default,Default,11111111,Empty,RyuJit,Default,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,3.442 ns,2.3747 ns,0.1302 ns,0.0064,0.0000,40 B +EmptyDocument,ShortRun,False,Default,Default,Default,Default,Default,Default,11111111,Empty,RyuJit,Default,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,397.830 ns,46.9921 ns,2.5758 ns,0.1807,0.0005,1136 B +EmptyApiEncoding,ShortRun,False,Default,Default,Default,Default,Default,Default,11111111,Empty,RyuJit,Default,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,3.879 ns,3.0270 ns,0.1659 ns,0.0089,0.0000,56 B +EmptyApiExample,ShortRun,False,Default,Default,Default,Default,Default,Default,11111111,Empty,RyuJit,Default,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,4.045 ns,6.0543 ns,0.3319 ns,0.0089,0.0000,56 B +EmptyApiExternalDocs,ShortRun,False,Default,Default,Default,Default,Default,Default,11111111,Empty,RyuJit,Default,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,3.455 ns,2.1233 ns,0.1164 ns,0.0064,0.0000,40 B +EmptyApiHeader,ShortRun,False,Default,Default,Default,Default,Default,Default,11111111,Empty,RyuJit,Default,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,4.633 ns,3.8933 ns,0.2134 ns,0.0127,0.0000,80 B +EmptyApiInfo,ShortRun,False,Default,Default,Default,Default,Default,Default,11111111,Empty,RyuJit,Default,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,4.462 ns,4.0279 ns,0.2208 ns,0.0127,0.0000,80 B +EmptyApiLicense,ShortRun,False,Default,Default,Default,Default,Default,Default,11111111,Empty,RyuJit,Default,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,3.670 ns,1.6839 ns,0.0923 ns,0.0076,0.0000,48 B +EmptyApiLink,ShortRun,False,Default,Default,Default,Default,Default,Default,11111111,Empty,RyuJit,Default,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,4.388 ns,1.9826 ns,0.1087 ns,0.0115,0.0000,72 B +EmptyApiMediaType,ShortRun,False,Default,Default,Default,Default,Default,Default,11111111,Empty,RyuJit,Default,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,3.857 ns,1.4731 ns,0.0807 ns,0.0089,0.0000,56 B +EmptyApiOAuthFlow,ShortRun,False,Default,Default,Default,Default,Default,Default,11111111,Empty,RyuJit,Default,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,3.810 ns,1.1359 ns,0.0623 ns,0.0089,0.0000,56 B +EmptyApiOAuthFlows,ShortRun,False,Default,Default,Default,Default,Default,Default,11111111,Empty,RyuJit,Default,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,3.979 ns,5.5181 ns,0.3025 ns,0.0089,0.0000,56 B +EmptyApiOperation,ShortRun,False,Default,Default,Default,Default,Default,Default,11111111,Empty,RyuJit,Default,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,72.530 ns,230.3314 ns,12.6252 ns,0.0599,0.0001,376 B +EmptyApiParameter,ShortRun,False,Default,Default,Default,Default,Default,Default,11111111,Empty,RyuJit,Default,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,4.919 ns,3.2142 ns,0.1762 ns,0.0153,0.0000,96 B +EmptyApiPathItem,ShortRun,False,Default,Default,Default,Default,Default,Default,11111111,Empty,RyuJit,Default,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,3.966 ns,0.7140 ns,0.0391 ns,0.0102,0.0000,64 B +EmptyApiPaths,ShortRun,False,Default,Default,Default,Default,Default,Default,11111111,Empty,RyuJit,Default,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,56.222 ns,32.3248 ns,1.7718 ns,0.0395,0.0000,248 B +EmptyApiRequestBody,ShortRun,False,Default,Default,Default,Default,Default,Default,11111111,Empty,RyuJit,Default,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,3.683 ns,2.3246 ns,0.1274 ns,0.0076,0.0000,48 B +EmptyApiResponse,ShortRun,False,Default,Default,Default,Default,Default,Default,11111111,Empty,RyuJit,Default,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,3.864 ns,0.9334 ns,0.0512 ns,0.0089,0.0000,56 B +EmptyApiResponses,ShortRun,False,Default,Default,Default,Default,Default,Default,11111111,Empty,RyuJit,Default,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,49.325 ns,7.2131 ns,0.3954 ns,0.0395,0.0000,248 B +EmptyApiSchema,ShortRun,False,Default,Default,Default,Default,Default,Default,11111111,Empty,RyuJit,Default,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,12.565 ns,2.0834 ns,0.1142 ns,0.0650,0.0000,408 B +EmptyApiSecurityRequirement,ShortRun,False,Default,Default,Default,Default,Default,Default,11111111,Empty,RyuJit,Default,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,8.411 ns,1.5393 ns,0.0844 ns,0.0166,0.0000,104 B +EmptyApiSecurityScheme,ShortRun,False,Default,Default,Default,Default,Default,Default,11111111,Empty,RyuJit,Default,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,4.719 ns,3.8028 ns,0.2084 ns,0.0140,0.0000,88 B +EmptyApiServer,ShortRun,False,Default,Default,Default,Default,Default,Default,11111111,Empty,RyuJit,Default,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,3.626 ns,0.4928 ns,0.0270 ns,0.0076,0.0000,48 B +EmptyApiServerVariable,ShortRun,False,Default,Default,Default,Default,Default,Default,11111111,Empty,RyuJit,Default,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,3.589 ns,0.2983 ns,0.0164 ns,0.0076,0.0000,48 B +EmptyApiTag,ShortRun,False,Default,Default,Default,Default,Default,Default,11111111,Empty,RyuJit,Default,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,3.889 ns,7.4113 ns,0.4062 ns,0.0076,0.0000,48 B diff --git a/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.EmptyModels-report.html b/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.EmptyModels-report.html new file mode 100644 index 000000000..f04a01eba --- /dev/null +++ b/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.EmptyModels-report.html @@ -0,0 +1,59 @@ + + + + +performance.EmptyModels-20250409-150626 + + + + +

+BenchmarkDotNet v0.14.0, Windows 11 (10.0.26100.3476)
+11th Gen Intel Core i7-1185G7 3.00GHz, 1 CPU, 8 logical and 4 physical cores
+.NET SDK 8.0.408
+  [Host]   : .NET 8.0.15 (8.0.1525.16413), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI
+  ShortRun : .NET 8.0.15 (8.0.1525.16413), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI
+
+
Job=ShortRun  IterationCount=3  LaunchCount=1  
+WarmupCount=3  
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Method MeanErrorStdDevGen0Gen1Allocated
EmptyApiCallback4.557 ns2.2807 ns0.1250 ns0.0051-32 B
EmptyApiComponents5.116 ns0.6915 ns0.0379 ns0.0166-104 B
EmptyApiContact3.759 ns3.1240 ns0.1712 ns0.0076-48 B
EmptyApiDiscriminator3.442 ns2.3747 ns0.1302 ns0.0064-40 B
EmptyDocument397.830 ns46.9921 ns2.5758 ns0.18070.00051136 B
EmptyApiEncoding3.879 ns3.0270 ns0.1659 ns0.0089-56 B
EmptyApiExample4.045 ns6.0543 ns0.3319 ns0.0089-56 B
EmptyApiExternalDocs3.455 ns2.1233 ns0.1164 ns0.0064-40 B
EmptyApiHeader4.633 ns3.8933 ns0.2134 ns0.0127-80 B
EmptyApiInfo4.462 ns4.0279 ns0.2208 ns0.0127-80 B
EmptyApiLicense3.670 ns1.6839 ns0.0923 ns0.0076-48 B
EmptyApiLink4.388 ns1.9826 ns0.1087 ns0.0115-72 B
EmptyApiMediaType3.857 ns1.4731 ns0.0807 ns0.0089-56 B
EmptyApiOAuthFlow3.810 ns1.1359 ns0.0623 ns0.0089-56 B
EmptyApiOAuthFlows3.979 ns5.5181 ns0.3025 ns0.0089-56 B
EmptyApiOperation72.530 ns230.3314 ns12.6252 ns0.05990.0001376 B
EmptyApiParameter4.919 ns3.2142 ns0.1762 ns0.0153-96 B
EmptyApiPathItem3.966 ns0.7140 ns0.0391 ns0.0102-64 B
EmptyApiPaths56.222 ns32.3248 ns1.7718 ns0.0395-248 B
EmptyApiRequestBody3.683 ns2.3246 ns0.1274 ns0.0076-48 B
EmptyApiResponse3.864 ns0.9334 ns0.0512 ns0.0089-56 B
EmptyApiResponses49.325 ns7.2131 ns0.3954 ns0.0395-248 B
EmptyApiSchema12.565 ns2.0834 ns0.1142 ns0.0650-408 B
EmptyApiSecurityRequirement8.411 ns1.5393 ns0.0844 ns0.0166-104 B
EmptyApiSecurityScheme4.719 ns3.8028 ns0.2084 ns0.0140-88 B
EmptyApiServer3.626 ns0.4928 ns0.0270 ns0.0076-48 B
EmptyApiServerVariable3.589 ns0.2983 ns0.0164 ns0.0076-48 B
EmptyApiTag3.889 ns7.4113 ns0.4062 ns0.0076-48 B
+ + diff --git a/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.EmptyModels-report.json b/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.EmptyModels-report.json new file mode 100644 index 000000000..943851dde --- /dev/null +++ b/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.EmptyModels-report.json @@ -0,0 +1 @@ +{"Title":"performance.EmptyModels-20250409-150626","HostEnvironmentInfo":{"BenchmarkDotNetCaption":"BenchmarkDotNet","BenchmarkDotNetVersion":"0.14.0","OsVersion":"Windows 11 (10.0.26100.3476)","ProcessorName":"11th Gen Intel Core i7-1185G7 3.00GHz","PhysicalProcessorCount":1,"PhysicalCoreCount":4,"LogicalCoreCount":8,"RuntimeVersion":".NET 8.0.15 (8.0.1525.16413)","Architecture":"X64","HasAttachedDebugger":false,"HasRyuJit":true,"Configuration":"RELEASE","DotNetCliVersion":"8.0.408","ChronometerFrequency":{"Hertz":10000000},"HardwareTimerKind":"Unknown"},"Benchmarks":[{"DisplayInfo":"EmptyModels.EmptyApiCallback: ShortRun(IterationCount=3, LaunchCount=1, WarmupCount=3)","Namespace":"performance","Type":"EmptyModels","Method":"EmptyApiCallback","MethodTitle":"EmptyApiCallback","Parameters":"","FullName":"performance.EmptyModels.EmptyApiCallback","HardwareIntrinsics":"AVX-512F+CD+BW+DQ+VL+VBMI,AES,BMI1,BMI2,FMA,LZCNT,PCLMUL,POPCNT VectorSize=256","Statistics":{"OriginalValues":[4.592856764793396,4.417923092842102,4.660089313983917],"N":3,"Min":4.417923092842102,"LowerFence":4.323765262961388,"Q1":4.505389928817749,"Median":4.592856764793396,"Mean":4.556956390539805,"Q3":4.626473039388657,"UpperFence":4.808097705245018,"Max":4.660089313983917,"InterquartileRange":0.12108311057090759,"LowerOutliers":[],"UpperOutliers":[],"AllOutliers":[],"StandardError":0.07217512803172468,"Variance":0.015627747319187552,"StandardDeviation":0.12501098879373584,"Skewness":-0.26349389511626564,"Kurtosis":0.6666666666666692,"ConfidenceInterval":{"N":3,"Mean":4.556956390539805,"StandardError":0.07217512803172468,"Level":12,"Margin":2.2806658005071028,"Lower":2.2762905900327026,"Upper":6.837622191046908},"Percentiles":{"P0":4.417923092842102,"P25":4.505389928817749,"P50":4.592856764793396,"P67":4.615715831518173,"P80":4.633196294307709,"P85":4.639919549226761,"P90":4.646642804145813,"P95":4.653366059064865,"P100":4.660089313983917}},"Memory":{"Gen0Collections":342,"Gen1Collections":0,"Gen2Collections":0,"TotalOperations":67108864,"BytesAllocatedPerOperation":32},"Measurements":[{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":224700},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":352200},{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":572700},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":548600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":1,"Operations":16,"Nanoseconds":2300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":2,"Operations":32,"Nanoseconds":1500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":3,"Operations":64,"Nanoseconds":1700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":4,"Operations":128,"Nanoseconds":15200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":5,"Operations":256,"Nanoseconds":12900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":6,"Operations":512,"Nanoseconds":14200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":7,"Operations":1024,"Nanoseconds":57500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":8,"Operations":2048,"Nanoseconds":99800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":9,"Operations":4096,"Nanoseconds":147200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":10,"Operations":8192,"Nanoseconds":335800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":11,"Operations":16384,"Nanoseconds":630700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":12,"Operations":32768,"Nanoseconds":918100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":13,"Operations":65536,"Nanoseconds":1803200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":14,"Operations":131072,"Nanoseconds":2989000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":15,"Operations":262144,"Nanoseconds":6247000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":16,"Operations":524288,"Nanoseconds":7583200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":17,"Operations":1048576,"Nanoseconds":16935200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":18,"Operations":2097152,"Nanoseconds":30574500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":19,"Operations":4194304,"Nanoseconds":50510100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":20,"Operations":8388608,"Nanoseconds":69991400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":21,"Operations":16777216,"Nanoseconds":121294000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":22,"Operations":33554432,"Nanoseconds":261849100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":23,"Operations":67108864,"Nanoseconds":552893400},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":263824000},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":222913500},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":222078700},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":4,"Operations":67108864,"Nanoseconds":233530000},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":5,"Operations":67108864,"Nanoseconds":224828700},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":6,"Operations":67108864,"Nanoseconds":221189700},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":7,"Operations":67108864,"Nanoseconds":223046600},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":8,"Operations":67108864,"Nanoseconds":226242200},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":9,"Operations":67108864,"Nanoseconds":242606500},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":10,"Operations":67108864,"Nanoseconds":231130800},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":225125700},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":227785500},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":234627100},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":4,"Operations":67108864,"Nanoseconds":234494500},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":5,"Operations":67108864,"Nanoseconds":223254200},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":6,"Operations":67108864,"Nanoseconds":231841800},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":7,"Operations":67108864,"Nanoseconds":237916800},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":8,"Operations":67108864,"Nanoseconds":220190700},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":9,"Operations":67108864,"Nanoseconds":221594500},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":10,"Operations":67108864,"Nanoseconds":223029500},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":11,"Operations":67108864,"Nanoseconds":233179200},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":12,"Operations":67108864,"Nanoseconds":229128100},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":13,"Operations":67108864,"Nanoseconds":224810800},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":14,"Operations":67108864,"Nanoseconds":221426200},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":15,"Operations":67108864,"Nanoseconds":223453100},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":523402100},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":525407100},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":510604900},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":533347100},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":521607500},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":537859000},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":308221400},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":296481800},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":312733300}],"Metrics":[{"Value":0.0050961971282958984,"Descriptor":{"Id":"Gen0Collects","DisplayName":"Gen0","Legend":"GC Generation 0 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":0}},{"Value":0,"Descriptor":{"Id":"Gen1Collects","DisplayName":"Gen1","Legend":"GC Generation 1 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":1}},{"Value":0,"Descriptor":{"Id":"Gen2Collects","DisplayName":"Gen2","Legend":"GC Generation 2 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":2}},{"Value":32,"Descriptor":{"Id":"Allocated Memory","DisplayName":"Allocated","Legend":"Allocated memory per single operation (managed only, inclusive, 1KB = 1024B)","NumberFormat":"0.##","UnitType":2,"Unit":"B","TheGreaterTheBetter":false,"PriorityInCategory":3}}]},{"DisplayInfo":"EmptyModels.EmptyApiComponents: ShortRun(IterationCount=3, LaunchCount=1, WarmupCount=3)","Namespace":"performance","Type":"EmptyModels","Method":"EmptyApiComponents","MethodTitle":"EmptyApiComponents","Parameters":"","FullName":"performance.EmptyModels.EmptyApiComponents","HardwareIntrinsics":"AVX-512F+CD+BW+DQ+VL+VBMI,AES,BMI1,BMI2,FMA,LZCNT,PCLMUL,POPCNT VectorSize=256","Statistics":{"OriginalValues":[5.159780383110046,5.097496509552002,5.0912171602249146],"N":3,"Min":5.0912171602249146,"LowerFence":5.042934417724609,"Q1":5.094356834888458,"Median":5.097496509552002,"Mean":5.116164684295654,"Q3":5.128638446331024,"UpperFence":5.180060863494873,"Max":5.159780383110046,"InterquartileRange":0.03428161144256592,"LowerOutliers":[],"UpperOutliers":[],"AllOutliers":[],"StandardError":0.021883056187331492,"Variance":0.001436604444293721,"StandardDeviation":0.037902565141342624,"Skewness":0.3730493902700499,"Kurtosis":0.6666666666666667,"ConfidenceInterval":{"N":3,"Mean":5.116164684295654,"StandardError":0.021883056187331492,"Level":12,"Margin":0.6914838839646419,"Lower":4.4246808003310125,"Upper":5.807648568260296},"Percentiles":{"P0":5.0912171602249146,"P25":5.094356834888458,"P50":5.097496509552002,"P67":5.118673026561737,"P80":5.134866833686829,"P85":5.141095221042633,"P90":5.1473236083984375,"P95":5.153551995754242,"P100":5.159780383110046}},"Memory":{"Gen0Collections":1112,"Gen1Collections":0,"Gen2Collections":0,"TotalOperations":67108864,"BytesAllocatedPerOperation":104},"Measurements":[{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":216500},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":362100},{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":419500},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":553400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":1,"Operations":16,"Nanoseconds":1800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":2,"Operations":32,"Nanoseconds":1500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":3,"Operations":64,"Nanoseconds":9600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":4,"Operations":128,"Nanoseconds":17500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":5,"Operations":256,"Nanoseconds":17100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":6,"Operations":512,"Nanoseconds":27700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":7,"Operations":1024,"Nanoseconds":140900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":8,"Operations":2048,"Nanoseconds":138600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":9,"Operations":4096,"Nanoseconds":438400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":10,"Operations":8192,"Nanoseconds":366500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":11,"Operations":16384,"Nanoseconds":924900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":12,"Operations":32768,"Nanoseconds":1702400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":13,"Operations":65536,"Nanoseconds":2498300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":14,"Operations":131072,"Nanoseconds":4981500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":15,"Operations":262144,"Nanoseconds":4761500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":16,"Operations":524288,"Nanoseconds":9416200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":17,"Operations":1048576,"Nanoseconds":16734500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":18,"Operations":2097152,"Nanoseconds":36261800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":19,"Operations":4194304,"Nanoseconds":67590200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":20,"Operations":8388608,"Nanoseconds":96917300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":21,"Operations":16777216,"Nanoseconds":162477700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":22,"Operations":33554432,"Nanoseconds":296064400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":23,"Operations":67108864,"Nanoseconds":589678400},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":261356900},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":232349300},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":214844400},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":4,"Operations":67108864,"Nanoseconds":218763700},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":5,"Operations":67108864,"Nanoseconds":220580500},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":6,"Operations":67108864,"Nanoseconds":219876800},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":7,"Operations":67108864,"Nanoseconds":218196800},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":8,"Operations":67108864,"Nanoseconds":217610900},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":9,"Operations":67108864,"Nanoseconds":222883100},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":10,"Operations":67108864,"Nanoseconds":223730400},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":220021800},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":221326400},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":228020000},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":4,"Operations":67108864,"Nanoseconds":214995400},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":5,"Operations":67108864,"Nanoseconds":217538100},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":6,"Operations":67108864,"Nanoseconds":218945600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":7,"Operations":67108864,"Nanoseconds":214977700},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":8,"Operations":67108864,"Nanoseconds":215993800},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":9,"Operations":67108864,"Nanoseconds":215500000},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":10,"Operations":67108864,"Nanoseconds":216592000},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":11,"Operations":67108864,"Nanoseconds":217611200},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":12,"Operations":67108864,"Nanoseconds":216557300},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":13,"Operations":67108864,"Nanoseconds":215428600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":14,"Operations":67108864,"Nanoseconds":215673700},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":15,"Operations":67108864,"Nanoseconds":222007100},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":556685900},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":573913900},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":557209900},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":562859000},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":558679200},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":558257800},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":346267000},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":342087200},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":341665800}],"Metrics":[{"Value":0.016570091247558594,"Descriptor":{"Id":"Gen0Collects","DisplayName":"Gen0","Legend":"GC Generation 0 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":0}},{"Value":0,"Descriptor":{"Id":"Gen1Collects","DisplayName":"Gen1","Legend":"GC Generation 1 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":1}},{"Value":0,"Descriptor":{"Id":"Gen2Collects","DisplayName":"Gen2","Legend":"GC Generation 2 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":2}},{"Value":104,"Descriptor":{"Id":"Allocated Memory","DisplayName":"Allocated","Legend":"Allocated memory per single operation (managed only, inclusive, 1KB = 1024B)","NumberFormat":"0.##","UnitType":2,"Unit":"B","TheGreaterTheBetter":false,"PriorityInCategory":3}}]},{"DisplayInfo":"EmptyModels.EmptyApiContact: ShortRun(IterationCount=3, LaunchCount=1, WarmupCount=3)","Namespace":"performance","Type":"EmptyModels","Method":"EmptyApiContact","MethodTitle":"EmptyApiContact","Parameters":"","FullName":"performance.EmptyModels.EmptyApiContact","HardwareIntrinsics":"AVX-512F+CD+BW+DQ+VL+VBMI,AES,BMI1,BMI2,FMA,LZCNT,PCLMUL,POPCNT VectorSize=256","Statistics":{"OriginalValues":[3.8208946585655212,3.565061092376709,3.890150785446167],"N":3,"Min":3.565061092376709,"LowerFence":3.4491606056690216,"Q1":3.692977875471115,"Median":3.8208946585655212,"Mean":3.7587021787961326,"Q3":3.855522722005844,"UpperFence":4.099339991807938,"Max":3.890150785446167,"InterquartileRange":0.162544846534729,"LowerOutliers":[],"UpperOutliers":[],"AllOutliers":[],"StandardError":0.09886313020180643,"Variance":0.029321755539897985,"StandardDeviation":0.17123596450482587,"Skewness":-0.31528725697104965,"Kurtosis":0.6666666666666676,"ConfidenceInterval":{"N":3,"Mean":3.7587021787961326,"StandardError":0.09886313020180643,"Level":12,"Margin":3.1239814342031154,"Lower":0.6347207445930172,"Upper":6.882683612999248},"Percentiles":{"P0":3.565061092376709,"P25":3.692977875471115,"P50":3.8208946585655212,"P67":3.844441741704941,"P80":3.8624483346939087,"P85":3.8693739473819733,"P90":3.876299560070038,"P95":3.8832251727581024,"P100":3.890150785446167}},"Memory":{"Gen0Collections":513,"Gen1Collections":0,"Gen2Collections":0,"TotalOperations":67108864,"BytesAllocatedPerOperation":48},"Measurements":[{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":424600},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":229100},{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":421300},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":435300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":1,"Operations":16,"Nanoseconds":3000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":2,"Operations":32,"Nanoseconds":3900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":3,"Operations":64,"Nanoseconds":2800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":4,"Operations":128,"Nanoseconds":20600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":5,"Operations":256,"Nanoseconds":25100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":6,"Operations":512,"Nanoseconds":42100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":7,"Operations":1024,"Nanoseconds":55400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":8,"Operations":2048,"Nanoseconds":79100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":9,"Operations":4096,"Nanoseconds":145500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":10,"Operations":8192,"Nanoseconds":280200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":11,"Operations":16384,"Nanoseconds":395100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":12,"Operations":32768,"Nanoseconds":811800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":13,"Operations":65536,"Nanoseconds":1707400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":14,"Operations":131072,"Nanoseconds":3837700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":15,"Operations":262144,"Nanoseconds":5323500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":16,"Operations":524288,"Nanoseconds":9963800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":17,"Operations":1048576,"Nanoseconds":13318300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":18,"Operations":2097152,"Nanoseconds":25126500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":19,"Operations":4194304,"Nanoseconds":44259800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":20,"Operations":8388608,"Nanoseconds":64068500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":21,"Operations":16777216,"Nanoseconds":115778800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":22,"Operations":33554432,"Nanoseconds":230549800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":23,"Operations":67108864,"Nanoseconds":511454300},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":269875900},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":223722400},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":217369900},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":4,"Operations":67108864,"Nanoseconds":213560300},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":5,"Operations":67108864,"Nanoseconds":215029000},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":6,"Operations":67108864,"Nanoseconds":213591600},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":7,"Operations":67108864,"Nanoseconds":219704800},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":8,"Operations":67108864,"Nanoseconds":230156800},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":9,"Operations":67108864,"Nanoseconds":221868100},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":218228800},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":216032000},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":218497200},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":4,"Operations":67108864,"Nanoseconds":215816700},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":5,"Operations":67108864,"Nanoseconds":216868900},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":6,"Operations":67108864,"Nanoseconds":217334400},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":7,"Operations":67108864,"Nanoseconds":211869200},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":8,"Operations":67108864,"Nanoseconds":211910800},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":9,"Operations":67108864,"Nanoseconds":214909900},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":10,"Operations":67108864,"Nanoseconds":215571100},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":11,"Operations":67108864,"Nanoseconds":214083000},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":12,"Operations":67108864,"Nanoseconds":212801900},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":13,"Operations":67108864,"Nanoseconds":221002400},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":14,"Operations":67108864,"Nanoseconds":214760400},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":15,"Operations":67108864,"Nanoseconds":216676200},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":471871700},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":458207600},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":451400800},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":472232600},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":455063900},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":476880300},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":256415900},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":239247200},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":261063600}],"Metrics":[{"Value":0.007644295692443848,"Descriptor":{"Id":"Gen0Collects","DisplayName":"Gen0","Legend":"GC Generation 0 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":0}},{"Value":0,"Descriptor":{"Id":"Gen1Collects","DisplayName":"Gen1","Legend":"GC Generation 1 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":1}},{"Value":0,"Descriptor":{"Id":"Gen2Collects","DisplayName":"Gen2","Legend":"GC Generation 2 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":2}},{"Value":48,"Descriptor":{"Id":"Allocated Memory","DisplayName":"Allocated","Legend":"Allocated memory per single operation (managed only, inclusive, 1KB = 1024B)","NumberFormat":"0.##","UnitType":2,"Unit":"B","TheGreaterTheBetter":false,"PriorityInCategory":3}}]},{"DisplayInfo":"EmptyModels.EmptyApiDiscriminator: ShortRun(IterationCount=3, LaunchCount=1, WarmupCount=3)","Namespace":"performance","Type":"EmptyModels","Method":"EmptyApiDiscriminator","MethodTitle":"EmptyApiDiscriminator","Parameters":"","FullName":"performance.EmptyModels.EmptyApiDiscriminator","HardwareIntrinsics":"AVX-512F+CD+BW+DQ+VL+VBMI,AES,BMI1,BMI2,FMA,LZCNT,PCLMUL,POPCNT VectorSize=256","Statistics":{"OriginalValues":[3.5626962780952454,3.3040598034858704,3.4590788185596466],"N":3,"Min":3.3040598034858704,"LowerFence":3.1875919550657272,"Q1":3.3815693110227585,"Median":3.4590788185596466,"Mean":3.4419449667135873,"Q3":3.510887548327446,"UpperFence":3.7048649042844772,"Max":3.5626962780952454,"InterquartileRange":0.1293182373046875,"LowerOutliers":[],"UpperOutliers":[],"AllOutliers":[],"StandardError":0.07515180893565482,"Variance":0.016943383158903497,"StandardDeviation":0.13016675135726288,"Skewness":-0.12934933570213053,"Kurtosis":0.6666666666666662,"ConfidenceInterval":{"N":3,"Mean":3.4419449667135873,"StandardError":0.07515180893565482,"Level":12,"Margin":2.3747261024664144,"Lower":1.067218864247173,"Upper":5.816671069180002},"Percentiles":{"P0":3.3040598034858704,"P25":3.3815693110227585,"P50":3.4590788185596466,"P67":3.49430875480175,"P80":3.521249294281006,"P85":3.5316110402345657,"P90":3.5419727861881256,"P95":3.5523345321416855,"P100":3.5626962780952454}},"Memory":{"Gen0Collections":855,"Gen1Collections":0,"Gen2Collections":0,"TotalOperations":134217728,"BytesAllocatedPerOperation":40},"Measurements":[{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":211100},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":202600},{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":377600},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":756100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":1,"Operations":16,"Nanoseconds":2000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":2,"Operations":32,"Nanoseconds":1700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":3,"Operations":64,"Nanoseconds":1500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":4,"Operations":128,"Nanoseconds":18300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":5,"Operations":256,"Nanoseconds":9600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":6,"Operations":512,"Nanoseconds":15300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":7,"Operations":1024,"Nanoseconds":27300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":8,"Operations":2048,"Nanoseconds":68900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":9,"Operations":4096,"Nanoseconds":108600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":10,"Operations":8192,"Nanoseconds":214300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":11,"Operations":16384,"Nanoseconds":356000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":12,"Operations":32768,"Nanoseconds":709200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":13,"Operations":65536,"Nanoseconds":1641500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":14,"Operations":131072,"Nanoseconds":3478300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":15,"Operations":262144,"Nanoseconds":3976800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":16,"Operations":524288,"Nanoseconds":6021500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":17,"Operations":1048576,"Nanoseconds":10607200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":18,"Operations":2097152,"Nanoseconds":28501200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":19,"Operations":4194304,"Nanoseconds":47659600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":20,"Operations":8388608,"Nanoseconds":76269000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":21,"Operations":16777216,"Nanoseconds":120064200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":22,"Operations":33554432,"Nanoseconds":221726900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":23,"Operations":67108864,"Nanoseconds":467812300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":24,"Operations":134217728,"Nanoseconds":928444900},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":465056200},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":440044600},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":425220400},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":4,"Operations":134217728,"Nanoseconds":424489900},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":5,"Operations":134217728,"Nanoseconds":433476800},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":6,"Operations":134217728,"Nanoseconds":424033800},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":7,"Operations":134217728,"Nanoseconds":424677100},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":8,"Operations":134217728,"Nanoseconds":433913300},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":9,"Operations":134217728,"Nanoseconds":423384800},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":433469200},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":427751800},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":428099800},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":4,"Operations":134217728,"Nanoseconds":433760900},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":5,"Operations":134217728,"Nanoseconds":428082700},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":6,"Operations":134217728,"Nanoseconds":434944500},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":7,"Operations":134217728,"Nanoseconds":436595500},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":8,"Operations":134217728,"Nanoseconds":428329000},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":9,"Operations":134217728,"Nanoseconds":437294400},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":10,"Operations":134217728,"Nanoseconds":431856400},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":11,"Operations":134217728,"Nanoseconds":432137200},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":12,"Operations":134217728,"Nanoseconds":423483100},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":13,"Operations":134217728,"Nanoseconds":433966500},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":14,"Operations":134217728,"Nanoseconds":427714200},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":15,"Operations":134217728,"Nanoseconds":426678200},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":905486300},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":908087500},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":895573400},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":910033400},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":875319800},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":896126100},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":478177000},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":443463400},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":464269700}],"Metrics":[{"Value":0.006370246410369873,"Descriptor":{"Id":"Gen0Collects","DisplayName":"Gen0","Legend":"GC Generation 0 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":0}},{"Value":0,"Descriptor":{"Id":"Gen1Collects","DisplayName":"Gen1","Legend":"GC Generation 1 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":1}},{"Value":0,"Descriptor":{"Id":"Gen2Collects","DisplayName":"Gen2","Legend":"GC Generation 2 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":2}},{"Value":40,"Descriptor":{"Id":"Allocated Memory","DisplayName":"Allocated","Legend":"Allocated memory per single operation (managed only, inclusive, 1KB = 1024B)","NumberFormat":"0.##","UnitType":2,"Unit":"B","TheGreaterTheBetter":false,"PriorityInCategory":3}}]},{"DisplayInfo":"EmptyModels.EmptyDocument: ShortRun(IterationCount=3, LaunchCount=1, WarmupCount=3)","Namespace":"performance","Type":"EmptyModels","Method":"EmptyDocument","MethodTitle":"EmptyDocument","Parameters":"","FullName":"performance.EmptyModels.EmptyDocument","HardwareIntrinsics":"AVX-512F+CD+BW+DQ+VL+VBMI,AES,BMI1,BMI2,FMA,LZCNT,PCLMUL,POPCNT VectorSize=256","Statistics":{"OriginalValues":[398.48694801330566,400.0138282775879,394.9894428253174],"N":3,"Min":394.9894428253174,"LowerFence":392.96990633010864,"Q1":396.7381954193115,"Median":398.48694801330566,"Mean":397.830073038737,"Q3":399.2503881454468,"UpperFence":403.01867723464966,"Max":400.0138282775879,"InterquartileRange":2.512192726135254,"LowerOutliers":[],"UpperOutliers":[],"AllOutliers":[],"StandardError":1.4871366046206422,"Variance":6.634725842407836,"StandardDeviation":2.5757961569984213,"Skewness":-0.23843329783172837,"Kurtosis":0.6666666666666736,"ConfidenceInterval":{"N":3,"Mean":397.830073038737,"StandardError":1.4871366046206422,"Level":12,"Margin":46.99211054187173,"Lower":350.83796249686526,"Upper":444.82218358060874},"Percentiles":{"P0":394.9894428253174,"P25":396.7381954193115,"P50":398.48694801330566,"P67":399.0060873031616,"P80":399.403076171875,"P85":399.5557641983032,"P90":399.70845222473145,"P95":399.86114025115967,"P100":400.0138282775879}},"Memory":{"Gen0Collections":379,"Gen1Collections":1,"Gen2Collections":0,"TotalOperations":2097152,"BytesAllocatedPerOperation":1136},"Measurements":[{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":195500},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":7553800},{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":418200},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":598000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":1,"Operations":16,"Nanoseconds":68500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":2,"Operations":32,"Nanoseconds":73300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":3,"Operations":64,"Nanoseconds":104900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":4,"Operations":128,"Nanoseconds":207800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":5,"Operations":256,"Nanoseconds":348100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":6,"Operations":512,"Nanoseconds":604700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":7,"Operations":1024,"Nanoseconds":1170900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":8,"Operations":2048,"Nanoseconds":2713500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":9,"Operations":4096,"Nanoseconds":5404100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":10,"Operations":8192,"Nanoseconds":9501100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":11,"Operations":16384,"Nanoseconds":16839200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":12,"Operations":32768,"Nanoseconds":39233400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":13,"Operations":65536,"Nanoseconds":60785600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":14,"Operations":131072,"Nanoseconds":108206300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":15,"Operations":262144,"Nanoseconds":104893200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":16,"Operations":524288,"Nanoseconds":217875300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":17,"Operations":1048576,"Nanoseconds":433249400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":18,"Operations":2097152,"Nanoseconds":858904100},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":2097152,"Nanoseconds":8272700},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":2097152,"Nanoseconds":8391000},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":2097152,"Nanoseconds":8345400},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":4,"Operations":2097152,"Nanoseconds":8051100},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":5,"Operations":2097152,"Nanoseconds":8250700},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":6,"Operations":2097152,"Nanoseconds":8106700},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":2097152,"Nanoseconds":8095300},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":2097152,"Nanoseconds":8257900},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":2097152,"Nanoseconds":7917000},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":4,"Operations":2097152,"Nanoseconds":8108800},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":5,"Operations":2097152,"Nanoseconds":8127400},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":6,"Operations":2097152,"Nanoseconds":8012800},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":7,"Operations":2097152,"Nanoseconds":8286600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":8,"Operations":2097152,"Nanoseconds":7918600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":9,"Operations":2097152,"Nanoseconds":8836100},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":10,"Operations":2097152,"Nanoseconds":7960700},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":11,"Operations":2097152,"Nanoseconds":8086100},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":12,"Operations":2097152,"Nanoseconds":8441900},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":13,"Operations":2097152,"Nanoseconds":8568700},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":14,"Operations":2097152,"Nanoseconds":8604900},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":15,"Operations":2097152,"Nanoseconds":8401900},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":2097152,"Nanoseconds":855858800},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":2097152,"Nanoseconds":852912800},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":2097152,"Nanoseconds":874056800},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":2097152,"Nanoseconds":843815100},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":2097152,"Nanoseconds":847017200},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":2097152,"Nanoseconds":836480300},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":1,"Operations":2097152,"Nanoseconds":835687700},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":2,"Operations":2097152,"Nanoseconds":838889800},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":3,"Operations":2097152,"Nanoseconds":828352900}],"Metrics":[{"Value":0.18072128295898438,"Descriptor":{"Id":"Gen0Collects","DisplayName":"Gen0","Legend":"GC Generation 0 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":0}},{"Value":0.000476837158203125,"Descriptor":{"Id":"Gen1Collects","DisplayName":"Gen1","Legend":"GC Generation 1 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":1}},{"Value":0,"Descriptor":{"Id":"Gen2Collects","DisplayName":"Gen2","Legend":"GC Generation 2 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":2}},{"Value":1136,"Descriptor":{"Id":"Allocated Memory","DisplayName":"Allocated","Legend":"Allocated memory per single operation (managed only, inclusive, 1KB = 1024B)","NumberFormat":"0.##","UnitType":2,"Unit":"B","TheGreaterTheBetter":false,"PriorityInCategory":3}}]},{"DisplayInfo":"EmptyModels.EmptyApiEncoding: ShortRun(IterationCount=3, LaunchCount=1, WarmupCount=3)","Namespace":"performance","Type":"EmptyModels","Method":"EmptyApiEncoding","MethodTitle":"EmptyApiEncoding","Parameters":"","FullName":"performance.EmptyModels.EmptyApiEncoding","HardwareIntrinsics":"AVX-512F+CD+BW+DQ+VL+VBMI,AES,BMI1,BMI2,FMA,LZCNT,PCLMUL,POPCNT VectorSize=256","Statistics":{"OriginalValues":[3.9077773690223694,3.7008345127105713,4.028959572315216],"N":3,"Min":3.7008345127105713,"LowerFence":3.5582121461629868,"Q1":3.8043059408664703,"Median":3.9077773690223694,"Mean":3.8791904846827188,"Q3":3.9683684706687927,"UpperFence":4.214462265372276,"Max":4.028959572315216,"InterquartileRange":0.1640625298023224,"LowerOutliers":[],"UpperOutliers":[],"AllOutliers":[],"StandardError":0.09579391273688243,"Variance":0.027529421152324332,"StandardDeviation":0.16591992391609975,"Skewness":-0.16717873880952652,"Kurtosis":0.6666666666666662,"ConfidenceInterval":{"N":3,"Mean":3.8791904846827188,"StandardError":0.09579391273688243,"Level":12,"Margin":3.026997064414475,"Lower":0.852193420268244,"Upper":6.906187549097194},"Percentiles":{"P0":3.7008345127105713,"P25":3.8043059408664703,"P50":3.9077773690223694,"P67":3.9489793181419373,"P80":3.9804866909980774,"P85":3.992604911327362,"P90":4.004723131656647,"P95":4.016841351985931,"P100":4.028959572315216}},"Memory":{"Gen0Collections":599,"Gen1Collections":0,"Gen2Collections":0,"TotalOperations":67108864,"BytesAllocatedPerOperation":56},"Measurements":[{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":217400},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":348000},{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":549500},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":390500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":1,"Operations":16,"Nanoseconds":2200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":2,"Operations":32,"Nanoseconds":1400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":3,"Operations":64,"Nanoseconds":2100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":4,"Operations":128,"Nanoseconds":9100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":5,"Operations":256,"Nanoseconds":13200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":6,"Operations":512,"Nanoseconds":17800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":7,"Operations":1024,"Nanoseconds":33500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":8,"Operations":2048,"Nanoseconds":58700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":9,"Operations":4096,"Nanoseconds":115700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":10,"Operations":8192,"Nanoseconds":225900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":11,"Operations":16384,"Nanoseconds":493000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":12,"Operations":32768,"Nanoseconds":1108800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":13,"Operations":65536,"Nanoseconds":1894000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":14,"Operations":131072,"Nanoseconds":2953300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":15,"Operations":262144,"Nanoseconds":3638500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":16,"Operations":524288,"Nanoseconds":7180500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":17,"Operations":1048576,"Nanoseconds":10376100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":18,"Operations":2097152,"Nanoseconds":24912500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":19,"Operations":4194304,"Nanoseconds":43821300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":20,"Operations":8388608,"Nanoseconds":63720500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":21,"Operations":16777216,"Nanoseconds":116664600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":22,"Operations":33554432,"Nanoseconds":241457000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":23,"Operations":67108864,"Nanoseconds":537041200},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":250716000},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":212338600},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":217225900},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":4,"Operations":67108864,"Nanoseconds":213011900},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":5,"Operations":67108864,"Nanoseconds":210766200},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":6,"Operations":67108864,"Nanoseconds":211922200},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":7,"Operations":67108864,"Nanoseconds":211080600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":215888500},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":210216600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":216014200},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":4,"Operations":67108864,"Nanoseconds":212714000},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":5,"Operations":67108864,"Nanoseconds":216149400},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":6,"Operations":67108864,"Nanoseconds":220179500},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":7,"Operations":67108864,"Nanoseconds":210301800},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":8,"Operations":67108864,"Nanoseconds":217311900},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":9,"Operations":67108864,"Nanoseconds":213710200},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":10,"Operations":67108864,"Nanoseconds":217312300},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":11,"Operations":67108864,"Nanoseconds":212514500},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":12,"Operations":67108864,"Nanoseconds":212027400},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":13,"Operations":67108864,"Nanoseconds":212729200},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":14,"Operations":67108864,"Nanoseconds":211187700},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":15,"Operations":67108864,"Nanoseconds":215775500},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":470427500},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":489235900},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":464414600},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":475956700},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":462069000},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":484089100},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":262246500},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":248358800},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":270378900}],"Metrics":[{"Value":0.008925795555114746,"Descriptor":{"Id":"Gen0Collects","DisplayName":"Gen0","Legend":"GC Generation 0 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":0}},{"Value":0,"Descriptor":{"Id":"Gen1Collects","DisplayName":"Gen1","Legend":"GC Generation 1 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":1}},{"Value":0,"Descriptor":{"Id":"Gen2Collects","DisplayName":"Gen2","Legend":"GC Generation 2 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":2}},{"Value":56,"Descriptor":{"Id":"Allocated Memory","DisplayName":"Allocated","Legend":"Allocated memory per single operation (managed only, inclusive, 1KB = 1024B)","NumberFormat":"0.##","UnitType":2,"Unit":"B","TheGreaterTheBetter":false,"PriorityInCategory":3}}]},{"DisplayInfo":"EmptyModels.EmptyApiExample: ShortRun(IterationCount=3, LaunchCount=1, WarmupCount=3)","Namespace":"performance","Type":"EmptyModels","Method":"EmptyApiExample","MethodTitle":"EmptyApiExample","Parameters":"","FullName":"performance.EmptyModels.EmptyApiExample","HardwareIntrinsics":"AVX-512F+CD+BW+DQ+VL+VBMI,AES,BMI1,BMI2,FMA,LZCNT,PCLMUL,POPCNT VectorSize=256","Statistics":{"OriginalValues":[3.9834290742874146,3.747483342885971,4.402700811624527],"N":3,"Min":3.747483342885971,"LowerFence":3.374043107032776,"Q1":3.865456208586693,"Median":3.9834290742874146,"Mean":4.044537742932637,"Q3":4.193064942955971,"UpperFence":4.684478044509888,"Max":4.402700811624527,"InterquartileRange":0.32760873436927795,"LowerOutliers":[],"UpperOutliers":[],"AllOutliers":[],"StandardError":0.19159695967728183,"Variance":0.11012818487273386,"StandardDeviation":0.3318556687367776,"Skewness":0.177898338557603,"Kurtosis":0.6666666666666674,"ConfidenceInterval":{"N":3,"Mean":4.044537742932637,"StandardError":0.19159695967728183,"Level":12,"Margin":6.054282761023227,"Lower":-2.00974501809059,"Upper":10.098820503955864},"Percentiles":{"P0":3.747483342885971,"P25":3.865456208586693,"P50":3.9834290742874146,"P67":4.125981464982033,"P80":4.234992116689682,"P85":4.276919290423393,"P90":4.3188464641571045,"P95":4.360773637890816,"P100":4.402700811624527}},"Memory":{"Gen0Collections":1198,"Gen1Collections":0,"Gen2Collections":0,"TotalOperations":134217728,"BytesAllocatedPerOperation":56},"Measurements":[{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":215000},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":206100},{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":447700},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":772600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":1,"Operations":16,"Nanoseconds":1900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":2,"Operations":32,"Nanoseconds":2900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":3,"Operations":64,"Nanoseconds":1900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":4,"Operations":128,"Nanoseconds":9200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":5,"Operations":256,"Nanoseconds":15300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":6,"Operations":512,"Nanoseconds":18800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":7,"Operations":1024,"Nanoseconds":43400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":8,"Operations":2048,"Nanoseconds":67900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":9,"Operations":4096,"Nanoseconds":132700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":10,"Operations":8192,"Nanoseconds":254400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":11,"Operations":16384,"Nanoseconds":424800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":12,"Operations":32768,"Nanoseconds":742400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":13,"Operations":65536,"Nanoseconds":1933600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":14,"Operations":131072,"Nanoseconds":2986700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":15,"Operations":262144,"Nanoseconds":3625100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":16,"Operations":524288,"Nanoseconds":7779000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":17,"Operations":1048576,"Nanoseconds":10245700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":18,"Operations":2097152,"Nanoseconds":24813200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":19,"Operations":4194304,"Nanoseconds":51278100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":20,"Operations":8388608,"Nanoseconds":74653500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":21,"Operations":16777216,"Nanoseconds":138273200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":22,"Operations":33554432,"Nanoseconds":258471100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":23,"Operations":67108864,"Nanoseconds":467676600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":24,"Operations":134217728,"Nanoseconds":971136400},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":466008900},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":424617000},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":434128400},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":4,"Operations":134217728,"Nanoseconds":423196500},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":5,"Operations":134217728,"Nanoseconds":428694200},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":6,"Operations":134217728,"Nanoseconds":424416100},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":438724500},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":426761400},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":433857700},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":4,"Operations":134217728,"Nanoseconds":428914700},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":5,"Operations":134217728,"Nanoseconds":430674000},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":6,"Operations":134217728,"Nanoseconds":428013300},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":7,"Operations":134217728,"Nanoseconds":432196300},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":8,"Operations":134217728,"Nanoseconds":431061100},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":9,"Operations":134217728,"Nanoseconds":426445100},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":10,"Operations":134217728,"Nanoseconds":423068800},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":11,"Operations":134217728,"Nanoseconds":440538600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":12,"Operations":134217728,"Nanoseconds":437942600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":13,"Operations":134217728,"Nanoseconds":446201600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":14,"Operations":134217728,"Nanoseconds":439572200},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":15,"Operations":134217728,"Nanoseconds":438113400},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":1012968300},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":950064500},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":944161000},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":966843100},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":935175000},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":1023116800},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":534646800},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":502978700},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":590920500}],"Metrics":[{"Value":0.008925795555114746,"Descriptor":{"Id":"Gen0Collects","DisplayName":"Gen0","Legend":"GC Generation 0 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":0}},{"Value":0,"Descriptor":{"Id":"Gen1Collects","DisplayName":"Gen1","Legend":"GC Generation 1 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":1}},{"Value":0,"Descriptor":{"Id":"Gen2Collects","DisplayName":"Gen2","Legend":"GC Generation 2 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":2}},{"Value":56,"Descriptor":{"Id":"Allocated Memory","DisplayName":"Allocated","Legend":"Allocated memory per single operation (managed only, inclusive, 1KB = 1024B)","NumberFormat":"0.##","UnitType":2,"Unit":"B","TheGreaterTheBetter":false,"PriorityInCategory":3}}]},{"DisplayInfo":"EmptyModels.EmptyApiExternalDocs: ShortRun(IterationCount=3, LaunchCount=1, WarmupCount=3)","Namespace":"performance","Type":"EmptyModels","Method":"EmptyApiExternalDocs","MethodTitle":"EmptyApiExternalDocs","Parameters":"","FullName":"performance.EmptyModels.EmptyApiExternalDocs","HardwareIntrinsics":"AVX-512F+CD+BW+DQ+VL+VBMI,AES,BMI1,BMI2,FMA,LZCNT,PCLMUL,POPCNT VectorSize=256","Statistics":{"OriginalValues":[3.587980568408966,3.4050501883029938,3.3718667924404144],"N":3,"Min":3.3718667924404144,"LowerFence":3.2263731583952904,"Q1":3.388458490371704,"Median":3.4050501883029938,"Mean":3.4549658497174582,"Q3":3.49651537835598,"UpperFence":3.6586007103323936,"Max":3.587980568408966,"InterquartileRange":0.10805688798427582,"LowerOutliers":[],"UpperOutliers":[],"AllOutliers":[],"StandardError":0.06719367773255386,"Variance":0.013544970981678913,"StandardDeviation":0.1163828637801928,"Skewness":0.3499979567391745,"Kurtosis":0.6666666666666647,"ConfidenceInterval":{"N":3,"Mean":3.4549658497174582,"StandardError":0.06719367773255386,"Level":12,"Margin":2.12325668127075,"Lower":1.3317091684467082,"Upper":5.578222530988208},"Percentiles":{"P0":3.3718667924404144,"P25":3.388458490371704,"P50":3.4050501883029938,"P67":3.4672465175390244,"P80":3.514808416366577,"P85":3.5331014543771744,"P90":3.5513944923877716,"P95":3.569687530398369,"P100":3.587980568408966}},"Memory":{"Gen0Collections":855,"Gen1Collections":0,"Gen2Collections":0,"TotalOperations":134217728,"BytesAllocatedPerOperation":40},"Measurements":[{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":275700},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":263500},{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":406400},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":560100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":1,"Operations":16,"Nanoseconds":1700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":2,"Operations":32,"Nanoseconds":2600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":3,"Operations":64,"Nanoseconds":3700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":4,"Operations":128,"Nanoseconds":12700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":5,"Operations":256,"Nanoseconds":35400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":6,"Operations":512,"Nanoseconds":29400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":7,"Operations":1024,"Nanoseconds":63100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":8,"Operations":2048,"Nanoseconds":73000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":9,"Operations":4096,"Nanoseconds":119300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":10,"Operations":8192,"Nanoseconds":222100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":11,"Operations":16384,"Nanoseconds":377200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":12,"Operations":32768,"Nanoseconds":667900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":13,"Operations":65536,"Nanoseconds":1195600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":14,"Operations":131072,"Nanoseconds":2724400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":15,"Operations":262144,"Nanoseconds":5084000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":16,"Operations":524288,"Nanoseconds":6166600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":17,"Operations":1048576,"Nanoseconds":13027000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":18,"Operations":2097152,"Nanoseconds":28184900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":19,"Operations":4194304,"Nanoseconds":46535400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":20,"Operations":8388608,"Nanoseconds":82736600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":21,"Operations":16777216,"Nanoseconds":122316600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":22,"Operations":33554432,"Nanoseconds":230313300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":23,"Operations":67108864,"Nanoseconds":457539900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":24,"Operations":134217728,"Nanoseconds":914037100},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":471823000},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":425180900},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":435222100},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":4,"Operations":134217728,"Nanoseconds":428011400},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":5,"Operations":134217728,"Nanoseconds":442100200},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":6,"Operations":134217728,"Nanoseconds":423840500},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":425941600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":426889500},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":425179900},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":4,"Operations":134217728,"Nanoseconds":436592600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":5,"Operations":134217728,"Nanoseconds":427383500},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":6,"Operations":134217728,"Nanoseconds":437702700},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":7,"Operations":134217728,"Nanoseconds":482485500},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":8,"Operations":134217728,"Nanoseconds":453285500},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":9,"Operations":134217728,"Nanoseconds":483140300},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":10,"Operations":134217728,"Nanoseconds":443749400},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":11,"Operations":134217728,"Nanoseconds":439202400},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":12,"Operations":134217728,"Nanoseconds":449024800},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":13,"Operations":134217728,"Nanoseconds":443626000},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":14,"Operations":134217728,"Nanoseconds":437346700},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":15,"Operations":134217728,"Nanoseconds":442418500},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":911746500},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":904197800},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":915840000},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":920773000},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":896220500},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":891766700},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":481570600},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":457018100},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":452564300}],"Metrics":[{"Value":0.006370246410369873,"Descriptor":{"Id":"Gen0Collects","DisplayName":"Gen0","Legend":"GC Generation 0 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":0}},{"Value":0,"Descriptor":{"Id":"Gen1Collects","DisplayName":"Gen1","Legend":"GC Generation 1 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":1}},{"Value":0,"Descriptor":{"Id":"Gen2Collects","DisplayName":"Gen2","Legend":"GC Generation 2 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":2}},{"Value":40,"Descriptor":{"Id":"Allocated Memory","DisplayName":"Allocated","Legend":"Allocated memory per single operation (managed only, inclusive, 1KB = 1024B)","NumberFormat":"0.##","UnitType":2,"Unit":"B","TheGreaterTheBetter":false,"PriorityInCategory":3}}]},{"DisplayInfo":"EmptyModels.EmptyApiHeader: ShortRun(IterationCount=3, LaunchCount=1, WarmupCount=3)","Namespace":"performance","Type":"EmptyModels","Method":"EmptyApiHeader","MethodTitle":"EmptyApiHeader","Parameters":"","FullName":"performance.EmptyModels.EmptyApiHeader","HardwareIntrinsics":"AVX-512F+CD+BW+DQ+VL+VBMI,AES,BMI1,BMI2,FMA,LZCNT,PCLMUL,POPCNT VectorSize=256","Statistics":{"OriginalValues":[4.591545462608337,4.864421486854553,4.443761706352234],"N":3,"Min":4.443761706352234,"LowerFence":4.202158749103546,"Q1":4.517653584480286,"Median":4.591545462608337,"Mean":4.6332428852717085,"Q3":4.727983474731445,"UpperFence":5.043478310108185,"Max":4.864421486854553,"InterquartileRange":0.21032989025115967,"LowerOutliers":[],"UpperOutliers":[],"AllOutliers":[],"StandardError":0.12321075308273044,"Variance":0.045542669025640706,"StandardDeviation":0.2134072843781128,"Skewness":0.18792960637439587,"Kurtosis":0.6666666666666656,"ConfidenceInterval":{"N":3,"Mean":4.6332428852717085,"StandardError":0.12321075308273044,"Level":12,"Margin":3.8933432953107237,"Lower":0.7398995899609848,"Upper":8.526586180582433},"Percentiles":{"P0":4.443761706352234,"P25":4.517653584480286,"P50":4.591545462608337,"P67":4.684323310852051,"P80":4.755271077156067,"P85":4.7825586795806885,"P90":4.80984628200531,"P95":4.837133884429932,"P100":4.864421486854553}},"Memory":{"Gen0Collections":855,"Gen1Collections":0,"Gen2Collections":0,"TotalOperations":67108864,"BytesAllocatedPerOperation":80},"Measurements":[{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":466600},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":215000},{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":424000},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":513400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":1,"Operations":16,"Nanoseconds":7300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":2,"Operations":32,"Nanoseconds":3600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":3,"Operations":64,"Nanoseconds":11500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":4,"Operations":128,"Nanoseconds":8800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":5,"Operations":256,"Nanoseconds":32400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":6,"Operations":512,"Nanoseconds":28200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":7,"Operations":1024,"Nanoseconds":63400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":8,"Operations":2048,"Nanoseconds":79700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":9,"Operations":4096,"Nanoseconds":159100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":10,"Operations":8192,"Nanoseconds":403100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":11,"Operations":16384,"Nanoseconds":491400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":12,"Operations":32768,"Nanoseconds":1057800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":13,"Operations":65536,"Nanoseconds":2771600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":14,"Operations":131072,"Nanoseconds":2973400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":15,"Operations":262144,"Nanoseconds":3603000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":16,"Operations":524288,"Nanoseconds":8845100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":17,"Operations":1048576,"Nanoseconds":15392100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":18,"Operations":2097152,"Nanoseconds":26346200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":19,"Operations":4194304,"Nanoseconds":56809300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":20,"Operations":8388608,"Nanoseconds":102389500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":21,"Operations":16777216,"Nanoseconds":141167600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":22,"Operations":33554432,"Nanoseconds":277458000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":23,"Operations":67108864,"Nanoseconds":539090100},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":255058300},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":219086100},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":216302400},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":4,"Operations":67108864,"Nanoseconds":214079200},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":5,"Operations":67108864,"Nanoseconds":215575600},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":6,"Operations":67108864,"Nanoseconds":215798600},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":7,"Operations":67108864,"Nanoseconds":221603200},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":8,"Operations":67108864,"Nanoseconds":226240700},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":9,"Operations":67108864,"Nanoseconds":218664200},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":10,"Operations":67108864,"Nanoseconds":220289000},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":218219100},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":220586600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":219150400},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":4,"Operations":67108864,"Nanoseconds":215036100},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":5,"Operations":67108864,"Nanoseconds":214569100},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":6,"Operations":67108864,"Nanoseconds":214601400},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":7,"Operations":67108864,"Nanoseconds":215709700},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":8,"Operations":67108864,"Nanoseconds":217906500},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":9,"Operations":67108864,"Nanoseconds":215937000},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":10,"Operations":67108864,"Nanoseconds":218931300},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":11,"Operations":67108864,"Nanoseconds":211572100},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":12,"Operations":67108864,"Nanoseconds":215422000},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":13,"Operations":67108864,"Nanoseconds":215113500},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":14,"Operations":67108864,"Nanoseconds":218077600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":15,"Operations":67108864,"Nanoseconds":214400500},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":516311000},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":519491400},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":522160700},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":523843100},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":542155500},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":513925500},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":308133400},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":326445800},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":298215800}],"Metrics":[{"Value":0.012740492820739746,"Descriptor":{"Id":"Gen0Collects","DisplayName":"Gen0","Legend":"GC Generation 0 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":0}},{"Value":0,"Descriptor":{"Id":"Gen1Collects","DisplayName":"Gen1","Legend":"GC Generation 1 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":1}},{"Value":0,"Descriptor":{"Id":"Gen2Collects","DisplayName":"Gen2","Legend":"GC Generation 2 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":2}},{"Value":80,"Descriptor":{"Id":"Allocated Memory","DisplayName":"Allocated","Legend":"Allocated memory per single operation (managed only, inclusive, 1KB = 1024B)","NumberFormat":"0.##","UnitType":2,"Unit":"B","TheGreaterTheBetter":false,"PriorityInCategory":3}}]},{"DisplayInfo":"EmptyModels.EmptyApiInfo: ShortRun(IterationCount=3, LaunchCount=1, WarmupCount=3)","Namespace":"performance","Type":"EmptyModels","Method":"EmptyApiInfo","MethodTitle":"EmptyApiInfo","Parameters":"","FullName":"performance.EmptyModels.EmptyApiInfo","HardwareIntrinsics":"AVX-512F+CD+BW+DQ+VL+VBMI,AES,BMI1,BMI2,FMA,LZCNT,PCLMUL,POPCNT VectorSize=256","Statistics":{"OriginalValues":[4.362562298774719,4.715491831302643,4.309205710887909],"N":3,"Min":4.309205710887909,"LowerFence":4.031169414520264,"Q1":4.335884004831314,"Median":4.362562298774719,"Mean":4.462419946988423,"Q3":4.539027065038681,"UpperFence":4.8437416553497314,"Max":4.715491831302643,"InterquartileRange":0.20314306020736694,"LowerOutliers":[],"UpperOutliers":[],"AllOutliers":[],"StandardError":0.1274699511525401,"Variance":0.04874576534049287,"StandardDeviation":0.2207844318345224,"Skewness":0.359765084430169,"Kurtosis":0.6666666666666686,"ConfidenceInterval":{"N":3,"Mean":4.462419946988423,"StandardError":0.1274699511525401,"Level":12,"Margin":4.02792992702589,"Lower":0.4344900199625332,"Upper":8.490349874014314},"Percentiles":{"P0":4.309205710887909,"P25":4.335884004831314,"P50":4.362562298774719,"P67":4.482558339834213,"P80":4.574320018291473,"P85":4.609612971544266,"P90":4.644905924797058,"P95":4.6801988780498505,"P100":4.715491831302643}},"Memory":{"Gen0Collections":855,"Gen1Collections":0,"Gen2Collections":0,"TotalOperations":67108864,"BytesAllocatedPerOperation":80},"Measurements":[{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":195700},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":361900},{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":429300},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":499200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":1,"Operations":16,"Nanoseconds":2900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":2,"Operations":32,"Nanoseconds":1600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":3,"Operations":64,"Nanoseconds":13700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":4,"Operations":128,"Nanoseconds":10200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":5,"Operations":256,"Nanoseconds":18300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":6,"Operations":512,"Nanoseconds":31700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":7,"Operations":1024,"Nanoseconds":43900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":8,"Operations":2048,"Nanoseconds":152000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":9,"Operations":4096,"Nanoseconds":182600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":10,"Operations":8192,"Nanoseconds":402100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":11,"Operations":16384,"Nanoseconds":533200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":12,"Operations":32768,"Nanoseconds":1104700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":13,"Operations":65536,"Nanoseconds":1964700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":14,"Operations":131072,"Nanoseconds":2621500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":15,"Operations":262144,"Nanoseconds":4961600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":16,"Operations":524288,"Nanoseconds":6871000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":17,"Operations":1048576,"Nanoseconds":12636800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":18,"Operations":2097152,"Nanoseconds":26787900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":19,"Operations":4194304,"Nanoseconds":48517300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":20,"Operations":8388608,"Nanoseconds":95703900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":21,"Operations":16777216,"Nanoseconds":129096900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":22,"Operations":33554432,"Nanoseconds":266100000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":23,"Operations":67108864,"Nanoseconds":537296000},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":255833500},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":210508200},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":214599900},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":4,"Operations":67108864,"Nanoseconds":217982000},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":5,"Operations":67108864,"Nanoseconds":214589600},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":6,"Operations":67108864,"Nanoseconds":213813400},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":7,"Operations":67108864,"Nanoseconds":216911300},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":8,"Operations":67108864,"Nanoseconds":215980700},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":212300600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":216608200},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":212851500},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":4,"Operations":67108864,"Nanoseconds":220612300},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":5,"Operations":67108864,"Nanoseconds":221036200},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":6,"Operations":67108864,"Nanoseconds":215491700},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":7,"Operations":67108864,"Nanoseconds":218539200},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":8,"Operations":67108864,"Nanoseconds":213431100},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":9,"Operations":67108864,"Nanoseconds":217589300},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":10,"Operations":67108864,"Nanoseconds":219519200},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":11,"Operations":67108864,"Nanoseconds":221107700},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":12,"Operations":67108864,"Nanoseconds":223008500},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":13,"Operations":67108864,"Nanoseconds":215336200},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":14,"Operations":67108864,"Nanoseconds":212394000},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":15,"Operations":67108864,"Nanoseconds":213769600},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":512687200},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":514363300},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":507614800},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":509374800},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":533059500},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":505794100},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":292766600},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":316451300},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":289185900}],"Metrics":[{"Value":0.012740492820739746,"Descriptor":{"Id":"Gen0Collects","DisplayName":"Gen0","Legend":"GC Generation 0 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":0}},{"Value":0,"Descriptor":{"Id":"Gen1Collects","DisplayName":"Gen1","Legend":"GC Generation 1 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":1}},{"Value":0,"Descriptor":{"Id":"Gen2Collects","DisplayName":"Gen2","Legend":"GC Generation 2 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":2}},{"Value":80,"Descriptor":{"Id":"Allocated Memory","DisplayName":"Allocated","Legend":"Allocated memory per single operation (managed only, inclusive, 1KB = 1024B)","NumberFormat":"0.##","UnitType":2,"Unit":"B","TheGreaterTheBetter":false,"PriorityInCategory":3}}]},{"DisplayInfo":"EmptyModels.EmptyApiLicense: ShortRun(IterationCount=3, LaunchCount=1, WarmupCount=3)","Namespace":"performance","Type":"EmptyModels","Method":"EmptyApiLicense","MethodTitle":"EmptyApiLicense","Parameters":"","FullName":"performance.EmptyModels.EmptyApiLicense","HardwareIntrinsics":"AVX-512F+CD+BW+DQ+VL+VBMI,AES,BMI1,BMI2,FMA,LZCNT,PCLMUL,POPCNT VectorSize=256","Statistics":{"OriginalValues":[3.7197083234786987,3.563976287841797,3.7276849150657654],"N":3,"Min":3.563976287841797,"LowerFence":3.5190608352422714,"Q1":3.641842305660248,"Median":3.7197083234786987,"Mean":3.67045650879542,"Q3":3.723696619272232,"UpperFence":3.8464780896902084,"Max":3.7276849150657654,"InterquartileRange":0.08185431361198425,"LowerOutliers":[],"UpperOutliers":[],"AllOutliers":[],"StandardError":0.05328988207307297,"Variance":0.00851943459408607,"StandardDeviation":0.09230078327991627,"Skewness":-0.38166881133914826,"Kurtosis":0.6666666666666641,"ConfidenceInterval":{"N":3,"Mean":3.67045650879542,"StandardError":0.05328988207307297,"Level":12,"Margin":1.6839098851849983,"Lower":1.986546623610422,"Upper":5.354366393980419},"Percentiles":{"P0":3.563976287841797,"P25":3.641842305660248,"P50":3.7197083234786987,"P67":3.7224203646183014,"P80":3.7244942784309387,"P85":3.7252919375896454,"P90":3.726089596748352,"P95":3.7268872559070587,"P100":3.7276849150657654}},"Memory":{"Gen0Collections":1026,"Gen1Collections":0,"Gen2Collections":0,"TotalOperations":134217728,"BytesAllocatedPerOperation":48},"Measurements":[{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":206100},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":283100},{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":414100},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":439900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":1,"Operations":16,"Nanoseconds":2100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":2,"Operations":32,"Nanoseconds":2100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":3,"Operations":64,"Nanoseconds":2000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":4,"Operations":128,"Nanoseconds":8900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":5,"Operations":256,"Nanoseconds":29500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":6,"Operations":512,"Nanoseconds":29000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":7,"Operations":1024,"Nanoseconds":54100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":8,"Operations":2048,"Nanoseconds":93600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":9,"Operations":4096,"Nanoseconds":129600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":10,"Operations":8192,"Nanoseconds":402500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":11,"Operations":16384,"Nanoseconds":777700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":12,"Operations":32768,"Nanoseconds":896700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":13,"Operations":65536,"Nanoseconds":1414500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":14,"Operations":131072,"Nanoseconds":3021700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":15,"Operations":262144,"Nanoseconds":5400500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":16,"Operations":524288,"Nanoseconds":8044800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":17,"Operations":1048576,"Nanoseconds":16746000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":18,"Operations":2097152,"Nanoseconds":28839600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":19,"Operations":4194304,"Nanoseconds":47408800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":20,"Operations":8388608,"Nanoseconds":84066600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":21,"Operations":16777216,"Nanoseconds":117290700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":22,"Operations":33554432,"Nanoseconds":239361600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":23,"Operations":67108864,"Nanoseconds":476464000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":24,"Operations":134217728,"Nanoseconds":931465300},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":471261500},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":428262400},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":430061200},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":4,"Operations":134217728,"Nanoseconds":437174800},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":5,"Operations":134217728,"Nanoseconds":427680400},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":6,"Operations":134217728,"Nanoseconds":427823400},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":7,"Operations":134217728,"Nanoseconds":426368800},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":430460500},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":435981700},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":426639700},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":4,"Operations":134217728,"Nanoseconds":441003900},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":5,"Operations":134217728,"Nanoseconds":442454200},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":6,"Operations":134217728,"Nanoseconds":441094600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":7,"Operations":134217728,"Nanoseconds":439834400},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":8,"Operations":134217728,"Nanoseconds":443438500},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":9,"Operations":134217728,"Nanoseconds":431040400},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":10,"Operations":134217728,"Nanoseconds":437328900},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":11,"Operations":134217728,"Nanoseconds":430896700},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":12,"Operations":134217728,"Nanoseconds":429765500},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":13,"Operations":134217728,"Nanoseconds":427990200},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":14,"Operations":134217728,"Nanoseconds":438945200},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":15,"Operations":134217728,"Nanoseconds":443725600},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":938235900},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":922059100},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":935272500},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":936579700},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":915677700},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":937650300},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":499250800},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":478348800},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":500321400}],"Metrics":[{"Value":0.007644295692443848,"Descriptor":{"Id":"Gen0Collects","DisplayName":"Gen0","Legend":"GC Generation 0 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":0}},{"Value":0,"Descriptor":{"Id":"Gen1Collects","DisplayName":"Gen1","Legend":"GC Generation 1 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":1}},{"Value":0,"Descriptor":{"Id":"Gen2Collects","DisplayName":"Gen2","Legend":"GC Generation 2 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":2}},{"Value":48,"Descriptor":{"Id":"Allocated Memory","DisplayName":"Allocated","Legend":"Allocated memory per single operation (managed only, inclusive, 1KB = 1024B)","NumberFormat":"0.##","UnitType":2,"Unit":"B","TheGreaterTheBetter":false,"PriorityInCategory":3}}]},{"DisplayInfo":"EmptyModels.EmptyApiLink: ShortRun(IterationCount=3, LaunchCount=1, WarmupCount=3)","Namespace":"performance","Type":"EmptyModels","Method":"EmptyApiLink","MethodTitle":"EmptyApiLink","Parameters":"","FullName":"performance.EmptyModels.EmptyApiLink","HardwareIntrinsics":"AVX-512F+CD+BW+DQ+VL+VBMI,AES,BMI1,BMI2,FMA,LZCNT,PCLMUL,POPCNT VectorSize=256","Statistics":{"OriginalValues":[4.507100582122803,4.294396936893463,4.362069070339203],"N":3,"Min":4.294396936893463,"LowerFence":4.168705269694328,"Q1":4.328233003616333,"Median":4.362069070339203,"Mean":4.387855529785156,"Q3":4.434584826231003,"UpperFence":4.5941125601530075,"Max":4.507100582122803,"InterquartileRange":0.1063518226146698,"LowerOutliers":[],"UpperOutliers":[],"AllOutliers":[],"StandardError":0.06274131092969644,"Variance":0.011809416291530539,"StandardDeviation":0.10867113826371075,"Skewness":0.22392814103051165,"Kurtosis":0.6666666666666667,"ConfidenceInterval":{"N":3,"Mean":4.387855529785156,"StandardError":0.06274131092969644,"Level":12,"Margin":1.9825661002422452,"Lower":2.4052894295429113,"Upper":6.370421630027401},"Percentiles":{"P0":4.294396936893463,"P25":4.328233003616333,"P50":4.362069070339203,"P67":4.411379784345627,"P80":4.449087977409363,"P85":4.463591128587723,"P90":4.478094279766083,"P95":4.492597430944443,"P100":4.507100582122803}},"Memory":{"Gen0Collections":770,"Gen1Collections":0,"Gen2Collections":0,"TotalOperations":67108864,"BytesAllocatedPerOperation":72},"Measurements":[{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":211200},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":239800},{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":441100},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":670300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":1,"Operations":16,"Nanoseconds":2800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":2,"Operations":32,"Nanoseconds":1700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":3,"Operations":64,"Nanoseconds":9500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":4,"Operations":128,"Nanoseconds":26100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":5,"Operations":256,"Nanoseconds":14400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":6,"Operations":512,"Nanoseconds":26000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":7,"Operations":1024,"Nanoseconds":56400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":8,"Operations":2048,"Nanoseconds":98000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":9,"Operations":4096,"Nanoseconds":153100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":10,"Operations":8192,"Nanoseconds":262700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":11,"Operations":16384,"Nanoseconds":418600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":12,"Operations":32768,"Nanoseconds":856000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":13,"Operations":65536,"Nanoseconds":2188100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":14,"Operations":131072,"Nanoseconds":3172500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":15,"Operations":262144,"Nanoseconds":3917600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":16,"Operations":524288,"Nanoseconds":9466300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":17,"Operations":1048576,"Nanoseconds":13171600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":18,"Operations":2097152,"Nanoseconds":28212000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":19,"Operations":4194304,"Nanoseconds":51871600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":20,"Operations":8388608,"Nanoseconds":89550200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":21,"Operations":16777216,"Nanoseconds":136625800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":22,"Operations":33554432,"Nanoseconds":273276100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":23,"Operations":67108864,"Nanoseconds":598244100},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":260132700},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":214773400},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":212934000},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":4,"Operations":67108864,"Nanoseconds":213889100},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":5,"Operations":67108864,"Nanoseconds":215750000},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":6,"Operations":67108864,"Nanoseconds":224746500},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":7,"Operations":67108864,"Nanoseconds":223265700},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":8,"Operations":67108864,"Nanoseconds":217757600},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":9,"Operations":67108864,"Nanoseconds":213382600},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":10,"Operations":67108864,"Nanoseconds":226390400},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":222558400},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":217942300},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":212477300},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":4,"Operations":67108864,"Nanoseconds":222352800},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":5,"Operations":67108864,"Nanoseconds":221637800},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":6,"Operations":67108864,"Nanoseconds":215066500},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":7,"Operations":67108864,"Nanoseconds":213347300},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":8,"Operations":67108864,"Nanoseconds":210915500},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":9,"Operations":67108864,"Nanoseconds":215080000},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":10,"Operations":67108864,"Nanoseconds":222600800},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":11,"Operations":67108864,"Nanoseconds":212781100},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":12,"Operations":67108864,"Nanoseconds":212702200},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":13,"Operations":67108864,"Nanoseconds":213151000},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":14,"Operations":67108864,"Nanoseconds":223262700},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":15,"Operations":67108864,"Nanoseconds":215322800},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":492699900},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":520873300},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":500967400},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":517546400},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":503272100},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":507813500},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":302466400},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":288192100},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":292733500}],"Metrics":[{"Value":0.011473894119262695,"Descriptor":{"Id":"Gen0Collects","DisplayName":"Gen0","Legend":"GC Generation 0 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":0}},{"Value":0,"Descriptor":{"Id":"Gen1Collects","DisplayName":"Gen1","Legend":"GC Generation 1 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":1}},{"Value":0,"Descriptor":{"Id":"Gen2Collects","DisplayName":"Gen2","Legend":"GC Generation 2 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":2}},{"Value":72,"Descriptor":{"Id":"Allocated Memory","DisplayName":"Allocated","Legend":"Allocated memory per single operation (managed only, inclusive, 1KB = 1024B)","NumberFormat":"0.##","UnitType":2,"Unit":"B","TheGreaterTheBetter":false,"PriorityInCategory":3}}]},{"DisplayInfo":"EmptyModels.EmptyApiMediaType: ShortRun(IterationCount=3, LaunchCount=1, WarmupCount=3)","Namespace":"performance","Type":"EmptyModels","Method":"EmptyApiMediaType","MethodTitle":"EmptyApiMediaType","Parameters":"","FullName":"performance.EmptyModels.EmptyApiMediaType","HardwareIntrinsics":"AVX-512F+CD+BW+DQ+VL+VBMI,AES,BMI1,BMI2,FMA,LZCNT,PCLMUL,POPCNT VectorSize=256","Statistics":{"OriginalValues":[3.8372568786144257,3.9463363587856293,3.788667172193527],"N":3,"Min":3.788667172193527,"LowerFence":3.6947101354599,"Q1":3.8129620254039764,"Median":3.8372568786144257,"Mean":3.857420136531194,"Q3":3.8917966187000275,"UpperFence":4.010048508644104,"Max":3.9463363587856293,"InterquartileRange":0.07883459329605103,"LowerOutliers":[],"UpperOutliers":[],"AllOutliers":[],"StandardError":0.04661834698741604,"Variance":0.006519810827517366,"StandardDeviation":0.08074534554708009,"Skewness":0.234142711661333,"Kurtosis":0.6666666666666649,"ConfidenceInterval":{"N":3,"Mean":3.857420136531194,"StandardError":0.04661834698741604,"Level":12,"Margin":1.4730956847577685,"Lower":2.3843244517734257,"Upper":5.330515821288962},"Percentiles":{"P0":3.788667172193527,"P25":3.8129620254039764,"P50":3.8372568786144257,"P67":3.874343901872635,"P80":3.902704566717148,"P85":3.913612514734268,"P90":3.9245204627513885,"P95":3.935428410768509,"P100":3.9463363587856293}},"Memory":{"Gen0Collections":1198,"Gen1Collections":0,"Gen2Collections":0,"TotalOperations":134217728,"BytesAllocatedPerOperation":56},"Measurements":[{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":235700},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":211800},{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":430100},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":509900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":1,"Operations":16,"Nanoseconds":2700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":2,"Operations":32,"Nanoseconds":2400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":3,"Operations":64,"Nanoseconds":1800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":4,"Operations":128,"Nanoseconds":9000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":5,"Operations":256,"Nanoseconds":18400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":6,"Operations":512,"Nanoseconds":29000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":7,"Operations":1024,"Nanoseconds":36200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":8,"Operations":2048,"Nanoseconds":82800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":9,"Operations":4096,"Nanoseconds":118100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":10,"Operations":8192,"Nanoseconds":230400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":11,"Operations":16384,"Nanoseconds":377100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":12,"Operations":32768,"Nanoseconds":989600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":13,"Operations":65536,"Nanoseconds":1801100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":14,"Operations":131072,"Nanoseconds":3202100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":15,"Operations":262144,"Nanoseconds":4095600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":16,"Operations":524288,"Nanoseconds":8328500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":17,"Operations":1048576,"Nanoseconds":11814200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":18,"Operations":2097152,"Nanoseconds":25894400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":19,"Operations":4194304,"Nanoseconds":51776700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":20,"Operations":8388608,"Nanoseconds":80438500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":21,"Operations":16777216,"Nanoseconds":119590700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":22,"Operations":33554432,"Nanoseconds":232002700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":23,"Operations":67108864,"Nanoseconds":498868700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":24,"Operations":134217728,"Nanoseconds":934848000},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":465457200},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":427500800},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":429576400},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":4,"Operations":134217728,"Nanoseconds":429661900},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":5,"Operations":134217728,"Nanoseconds":427386900},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":6,"Operations":134217728,"Nanoseconds":424458600},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":7,"Operations":134217728,"Nanoseconds":435316000},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":8,"Operations":134217728,"Nanoseconds":429012400},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":426807700},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":436906700},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":425514600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":4,"Operations":134217728,"Nanoseconds":428839600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":5,"Operations":134217728,"Nanoseconds":427374200},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":6,"Operations":134217728,"Nanoseconds":431394400},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":7,"Operations":134217728,"Nanoseconds":430727700},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":8,"Operations":134217728,"Nanoseconds":440379100},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":9,"Operations":134217728,"Nanoseconds":436388100},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":10,"Operations":134217728,"Nanoseconds":431384800},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":11,"Operations":134217728,"Nanoseconds":427488600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":12,"Operations":134217728,"Nanoseconds":425119000},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":13,"Operations":134217728,"Nanoseconds":433672100},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":14,"Operations":134217728,"Nanoseconds":429791200},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":15,"Operations":134217728,"Nanoseconds":428886300},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":942942600},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":928272300},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":949038800},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":944819100},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":959459500},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":938297500},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":515027900},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":529668300},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":508506300}],"Metrics":[{"Value":0.008925795555114746,"Descriptor":{"Id":"Gen0Collects","DisplayName":"Gen0","Legend":"GC Generation 0 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":0}},{"Value":0,"Descriptor":{"Id":"Gen1Collects","DisplayName":"Gen1","Legend":"GC Generation 1 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":1}},{"Value":0,"Descriptor":{"Id":"Gen2Collects","DisplayName":"Gen2","Legend":"GC Generation 2 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":2}},{"Value":56,"Descriptor":{"Id":"Allocated Memory","DisplayName":"Allocated","Legend":"Allocated memory per single operation (managed only, inclusive, 1KB = 1024B)","NumberFormat":"0.##","UnitType":2,"Unit":"B","TheGreaterTheBetter":false,"PriorityInCategory":3}}]},{"DisplayInfo":"EmptyModels.EmptyApiOAuthFlow: ShortRun(IterationCount=3, LaunchCount=1, WarmupCount=3)","Namespace":"performance","Type":"EmptyModels","Method":"EmptyApiOAuthFlow","MethodTitle":"EmptyApiOAuthFlow","Parameters":"","FullName":"performance.EmptyModels.EmptyApiOAuthFlow","HardwareIntrinsics":"AVX-512F+CD+BW+DQ+VL+VBMI,AES,BMI1,BMI2,FMA,LZCNT,PCLMUL,POPCNT VectorSize=256","Statistics":{"OriginalValues":[3.7840336561203003,3.7654660642147064,3.8813836872577667],"N":3,"Min":3.7654660642147064,"LowerFence":3.687811642885208,"Q1":3.7747498601675034,"Median":3.7840336561203003,"Mean":3.8102944691975913,"Q3":3.8327086716890335,"UpperFence":3.9196468889713287,"Max":3.8813836872577667,"InterquartileRange":0.05795881152153015,"LowerOutliers":[],"UpperOutliers":[],"AllOutliers":[],"StandardError":0.0359464720596174,"Variance":0.0038764465605985636,"StandardDeviation":0.062261115960112405,"Skewness":0.34674841969586334,"Kurtosis":0.6666666666666634,"ConfidenceInterval":{"N":3,"Mean":3.8102944691975913,"StandardError":0.0359464720596174,"Level":12,"Margin":1.135874527845912,"Lower":2.6744199413516796,"Upper":4.946168997043503},"Percentiles":{"P0":3.7654660642147064,"P25":3.7747498601675034,"P50":3.7840336561203003,"P67":3.817132666707039,"P80":3.84244367480278,"P85":3.852178677916527,"P90":3.8619136810302734,"P95":3.87164868414402,"P100":3.8813836872577667}},"Memory":{"Gen0Collections":1198,"Gen1Collections":0,"Gen2Collections":0,"TotalOperations":134217728,"BytesAllocatedPerOperation":56},"Measurements":[{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":204500},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":419900},{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":463600},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":524700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":1,"Operations":16,"Nanoseconds":2400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":2,"Operations":32,"Nanoseconds":1900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":3,"Operations":64,"Nanoseconds":1700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":4,"Operations":128,"Nanoseconds":11900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":5,"Operations":256,"Nanoseconds":20000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":6,"Operations":512,"Nanoseconds":28200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":7,"Operations":1024,"Nanoseconds":57900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":8,"Operations":2048,"Nanoseconds":90200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":9,"Operations":4096,"Nanoseconds":220600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":10,"Operations":8192,"Nanoseconds":310100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":11,"Operations":16384,"Nanoseconds":518800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":12,"Operations":32768,"Nanoseconds":836500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":13,"Operations":65536,"Nanoseconds":1469200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":14,"Operations":131072,"Nanoseconds":3178300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":15,"Operations":262144,"Nanoseconds":5688700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":16,"Operations":524288,"Nanoseconds":6771600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":17,"Operations":1048576,"Nanoseconds":18199600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":18,"Operations":2097152,"Nanoseconds":29810200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":19,"Operations":4194304,"Nanoseconds":50801500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":20,"Operations":8388608,"Nanoseconds":80043800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":21,"Operations":16777216,"Nanoseconds":117579900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":22,"Operations":33554432,"Nanoseconds":237182700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":23,"Operations":67108864,"Nanoseconds":490404700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":24,"Operations":134217728,"Nanoseconds":969846300},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":477064300},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":427183500},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":428887300},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":4,"Operations":134217728,"Nanoseconds":428359000},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":5,"Operations":134217728,"Nanoseconds":439537900},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":6,"Operations":134217728,"Nanoseconds":427226000},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":425919100},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":441784900},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":429217700},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":4,"Operations":134217728,"Nanoseconds":440141800},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":5,"Operations":134217728,"Nanoseconds":424708300},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":6,"Operations":134217728,"Nanoseconds":430781400},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":7,"Operations":134217728,"Nanoseconds":424812100},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":8,"Operations":134217728,"Nanoseconds":425722200},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":9,"Operations":134217728,"Nanoseconds":430760200},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":10,"Operations":134217728,"Nanoseconds":435458400},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":11,"Operations":134217728,"Nanoseconds":428818900},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":12,"Operations":134217728,"Nanoseconds":422882500},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":13,"Operations":134217728,"Nanoseconds":428879200},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":14,"Operations":134217728,"Nanoseconds":424858200},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":15,"Operations":134217728,"Nanoseconds":435466900},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":957145700},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":1063519800},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":940340000},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":936763600},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":934271500},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":949829700},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":507884400},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":505392300},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":520950500}],"Metrics":[{"Value":0.008925795555114746,"Descriptor":{"Id":"Gen0Collects","DisplayName":"Gen0","Legend":"GC Generation 0 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":0}},{"Value":0,"Descriptor":{"Id":"Gen1Collects","DisplayName":"Gen1","Legend":"GC Generation 1 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":1}},{"Value":0,"Descriptor":{"Id":"Gen2Collects","DisplayName":"Gen2","Legend":"GC Generation 2 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":2}},{"Value":56,"Descriptor":{"Id":"Allocated Memory","DisplayName":"Allocated","Legend":"Allocated memory per single operation (managed only, inclusive, 1KB = 1024B)","NumberFormat":"0.##","UnitType":2,"Unit":"B","TheGreaterTheBetter":false,"PriorityInCategory":3}}]},{"DisplayInfo":"EmptyModels.EmptyApiOAuthFlows: ShortRun(IterationCount=3, LaunchCount=1, WarmupCount=3)","Namespace":"performance","Type":"EmptyModels","Method":"EmptyApiOAuthFlows","MethodTitle":"EmptyApiOAuthFlows","Parameters":"","FullName":"performance.EmptyModels.EmptyApiOAuthFlows","HardwareIntrinsics":"AVX-512F+CD+BW+DQ+VL+VBMI,AES,BMI1,BMI2,FMA,LZCNT,PCLMUL,POPCNT VectorSize=256","Statistics":{"OriginalValues":[3.8228802382946014,3.78686860203743,4.327829927206039],"N":3,"Min":3.78686860203743,"LowerFence":3.3991534262895584,"Q1":3.8048744201660156,"Median":3.8228802382946014,"Mean":3.97919292251269,"Q3":4.07535508275032,"UpperFence":4.481076076626778,"Max":4.327829927206039,"InterquartileRange":0.2704806625843048,"LowerOutliers":[],"UpperOutliers":[],"AllOutliers":[],"StandardError":0.17462820530834694,"Variance":0.09148503026764251,"StandardDeviation":0.302464924028626,"Skewness":0.37877111735357105,"Kurtosis":0.6666666666666673,"ConfidenceInterval":{"N":3,"Mean":3.97919292251269,"StandardError":0.17462820530834694,"Level":12,"Margin":5.518086167794814,"Lower":-1.5388932452821238,"Upper":9.497279090307504},"Percentiles":{"P0":3.78686860203743,"P25":3.8048744201660156,"P50":3.8228802382946014,"P67":3.9945631325244904,"P80":4.125850051641464,"P85":4.176345020532608,"P90":4.226839989423752,"P95":4.277334958314896,"P100":4.327829927206039}},"Memory":{"Gen0Collections":1198,"Gen1Collections":0,"Gen2Collections":0,"TotalOperations":134217728,"BytesAllocatedPerOperation":56},"Measurements":[{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":331200},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":259100},{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":409800},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":410000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":1,"Operations":16,"Nanoseconds":2100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":2,"Operations":32,"Nanoseconds":2600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":3,"Operations":64,"Nanoseconds":2100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":4,"Operations":128,"Nanoseconds":13000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":5,"Operations":256,"Nanoseconds":35200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":6,"Operations":512,"Nanoseconds":32400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":7,"Operations":1024,"Nanoseconds":36300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":8,"Operations":2048,"Nanoseconds":79400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":9,"Operations":4096,"Nanoseconds":136700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":10,"Operations":8192,"Nanoseconds":257800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":11,"Operations":16384,"Nanoseconds":364300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":12,"Operations":32768,"Nanoseconds":916200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":13,"Operations":65536,"Nanoseconds":1984100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":14,"Operations":131072,"Nanoseconds":3660900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":15,"Operations":262144,"Nanoseconds":4141400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":16,"Operations":524288,"Nanoseconds":8551200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":17,"Operations":1048576,"Nanoseconds":15408700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":18,"Operations":2097152,"Nanoseconds":23939900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":19,"Operations":4194304,"Nanoseconds":45781900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":20,"Operations":8388608,"Nanoseconds":78534900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":21,"Operations":16777216,"Nanoseconds":120843000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":22,"Operations":33554432,"Nanoseconds":239313200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":23,"Operations":67108864,"Nanoseconds":491468500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":24,"Operations":134217728,"Nanoseconds":947993000},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":479442800},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":431768100},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":427858300},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":4,"Operations":134217728,"Nanoseconds":430068800},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":5,"Operations":134217728,"Nanoseconds":435144600},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":6,"Operations":134217728,"Nanoseconds":436612100},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":7,"Operations":134217728,"Nanoseconds":427583300},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":8,"Operations":134217728,"Nanoseconds":425967100},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":9,"Operations":134217728,"Nanoseconds":426106000},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":10,"Operations":134217728,"Nanoseconds":431069000},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":424163200},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":428968300},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":425619900},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":4,"Operations":134217728,"Nanoseconds":436892400},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":5,"Operations":134217728,"Nanoseconds":426043000},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":6,"Operations":134217728,"Nanoseconds":435992400},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":7,"Operations":134217728,"Nanoseconds":434857100},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":8,"Operations":134217728,"Nanoseconds":431607600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":9,"Operations":134217728,"Nanoseconds":430378500},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":10,"Operations":134217728,"Nanoseconds":437928100},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":11,"Operations":134217728,"Nanoseconds":432949500},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":12,"Operations":134217728,"Nanoseconds":424135700},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":13,"Operations":134217728,"Nanoseconds":424252700},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":14,"Operations":134217728,"Nanoseconds":430135600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":15,"Operations":134217728,"Nanoseconds":430194900},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":1046027400},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":950216900},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":941549200},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":943293200},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":938459800},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":1011066400},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":513098300},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":508264900},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":580871500}],"Metrics":[{"Value":0.008925795555114746,"Descriptor":{"Id":"Gen0Collects","DisplayName":"Gen0","Legend":"GC Generation 0 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":0}},{"Value":0,"Descriptor":{"Id":"Gen1Collects","DisplayName":"Gen1","Legend":"GC Generation 1 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":1}},{"Value":0,"Descriptor":{"Id":"Gen2Collects","DisplayName":"Gen2","Legend":"GC Generation 2 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":2}},{"Value":56,"Descriptor":{"Id":"Allocated Memory","DisplayName":"Allocated","Legend":"Allocated memory per single operation (managed only, inclusive, 1KB = 1024B)","NumberFormat":"0.##","UnitType":2,"Unit":"B","TheGreaterTheBetter":false,"PriorityInCategory":3}}]},{"DisplayInfo":"EmptyModels.EmptyApiOperation: ShortRun(IterationCount=3, LaunchCount=1, WarmupCount=3)","Namespace":"performance","Type":"EmptyModels","Method":"EmptyApiOperation","MethodTitle":"EmptyApiOperation","Parameters":"","FullName":"performance.EmptyModels.EmptyApiOperation","HardwareIntrinsics":"AVX-512F+CD+BW+DQ+VL+VBMI,AES,BMI1,BMI2,FMA,LZCNT,PCLMUL,POPCNT VectorSize=256","Statistics":{"OriginalValues":[80.5271327495575,79.08692955970764,57.9750657081604],"N":3,"Min":57.9750657081604,"LowerFence":51.6169473528862,"Q1":68.53099763393402,"Median":79.08692955970764,"Mean":72.52970933914185,"Q3":79.80703115463257,"UpperFence":96.72108143568039,"Max":80.5271327495575,"InterquartileRange":11.276033520698547,"LowerOutliers":[],"UpperOutliers":[],"AllOutliers":[],"StandardError":7.289187991485861,"Variance":159.396784725665,"StandardDeviation":12.625243947174447,"Skewness":-0.37927315132858713,"Kurtosis":0.6666666666666666,"ConfidenceInterval":{"N":3,"Mean":72.52970933914185,"StandardError":7.289187991485861,"Level":12,"Margin":230.33144822883676,"Lower":-157.80173888969492,"Upper":302.8611575679786},"Percentiles":{"P0":57.9750657081604,"P25":68.53099763393402,"P50":79.08692955970764,"P67":79.57659864425659,"P80":79.95105147361755,"P85":80.09507179260254,"P90":80.23909211158752,"P95":80.38311243057251,"P100":80.5271327495575}},"Memory":{"Gen0Collections":1005,"Gen1Collections":1,"Gen2Collections":0,"TotalOperations":16777216,"BytesAllocatedPerOperation":376},"Measurements":[{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":191100},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":849200},{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":426500},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":452000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":1,"Operations":16,"Nanoseconds":12300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":2,"Operations":32,"Nanoseconds":13100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":3,"Operations":64,"Nanoseconds":20600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":4,"Operations":128,"Nanoseconds":41400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":5,"Operations":256,"Nanoseconds":87100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":6,"Operations":512,"Nanoseconds":112800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":7,"Operations":1024,"Nanoseconds":279300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":8,"Operations":2048,"Nanoseconds":503200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":9,"Operations":4096,"Nanoseconds":952500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":10,"Operations":8192,"Nanoseconds":2182500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":11,"Operations":16384,"Nanoseconds":3113900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":12,"Operations":32768,"Nanoseconds":5016400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":13,"Operations":65536,"Nanoseconds":7625700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":14,"Operations":131072,"Nanoseconds":15675900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":15,"Operations":262144,"Nanoseconds":39758800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":16,"Operations":524288,"Nanoseconds":51789400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":17,"Operations":1048576,"Nanoseconds":71373300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":18,"Operations":2097152,"Nanoseconds":139815400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":19,"Operations":4194304,"Nanoseconds":255469900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":20,"Operations":8388608,"Nanoseconds":498235200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":21,"Operations":16777216,"Nanoseconds":999606800},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":16777216,"Nanoseconds":68519700},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":16777216,"Nanoseconds":68510700},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":16777216,"Nanoseconds":72668500},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":4,"Operations":16777216,"Nanoseconds":57994800},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":5,"Operations":16777216,"Nanoseconds":55180700},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":6,"Operations":16777216,"Nanoseconds":56829300},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":7,"Operations":16777216,"Nanoseconds":56936400},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":8,"Operations":16777216,"Nanoseconds":55615400},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":16777216,"Nanoseconds":58485000},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":16777216,"Nanoseconds":59251200},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":16777216,"Nanoseconds":58881600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":4,"Operations":16777216,"Nanoseconds":60900300},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":5,"Operations":16777216,"Nanoseconds":63883800},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":6,"Operations":16777216,"Nanoseconds":56097500},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":7,"Operations":16777216,"Nanoseconds":55900800},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":8,"Operations":16777216,"Nanoseconds":56957900},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":9,"Operations":16777216,"Nanoseconds":56110700},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":10,"Operations":16777216,"Nanoseconds":54858600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":11,"Operations":16777216,"Nanoseconds":60264600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":12,"Operations":16777216,"Nanoseconds":59704100},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":13,"Operations":16777216,"Nanoseconds":54823400},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":14,"Operations":16777216,"Nanoseconds":54298700},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":15,"Operations":16777216,"Nanoseconds":53021800},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":16,"Operations":16777216,"Nanoseconds":57560600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":17,"Operations":16777216,"Nanoseconds":55869100},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":16777216,"Nanoseconds":1217160000},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":16777216,"Nanoseconds":1485696500},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":16777216,"Nanoseconds":1220161600},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":16777216,"Nanoseconds":1407979000},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":16777216,"Nanoseconds":1383816400},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":16777216,"Nanoseconds":1029618100},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":1,"Operations":16777216,"Nanoseconds":1351021100},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":2,"Operations":16777216,"Nanoseconds":1326858500},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":3,"Operations":16777216,"Nanoseconds":972660200}],"Metrics":[{"Value":0.05990266799926758,"Descriptor":{"Id":"Gen0Collects","DisplayName":"Gen0","Legend":"GC Generation 0 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":0}},{"Value":5.9604644775390625e-05,"Descriptor":{"Id":"Gen1Collects","DisplayName":"Gen1","Legend":"GC Generation 1 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":1}},{"Value":0,"Descriptor":{"Id":"Gen2Collects","DisplayName":"Gen2","Legend":"GC Generation 2 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":2}},{"Value":376,"Descriptor":{"Id":"Allocated Memory","DisplayName":"Allocated","Legend":"Allocated memory per single operation (managed only, inclusive, 1KB = 1024B)","NumberFormat":"0.##","UnitType":2,"Unit":"B","TheGreaterTheBetter":false,"PriorityInCategory":3}}]},{"DisplayInfo":"EmptyModels.EmptyApiParameter: ShortRun(IterationCount=3, LaunchCount=1, WarmupCount=3)","Namespace":"performance","Type":"EmptyModels","Method":"EmptyApiParameter","MethodTitle":"EmptyApiParameter","Parameters":"","FullName":"performance.EmptyModels.EmptyApiParameter","HardwareIntrinsics":"AVX-512F+CD+BW+DQ+VL+VBMI,AES,BMI1,BMI2,FMA,LZCNT,PCLMUL,POPCNT VectorSize=256","Statistics":{"OriginalValues":[5.109083652496338,4.886192083358765,4.761295020580292],"N":3,"Min":4.761295020580292,"LowerFence":4.562902078032494,"Q1":4.823743551969528,"Median":4.886192083358765,"Mean":4.918856918811798,"Q3":4.997637867927551,"UpperFence":5.258479341864586,"Max":5.109083652496338,"InterquartileRange":0.17389431595802307,"LowerOutliers":[],"UpperOutliers":[],"AllOutliers":[],"StandardError":0.1017177086006317,"Variance":0.03103947672888907,"StandardDeviation":0.17618023932577986,"Skewness":0.17903240395700248,"Kurtosis":0.6666666666666665,"ConfidenceInterval":{"N":3,"Mean":4.918856918811798,"StandardError":0.1017177086006317,"Level":12,"Margin":3.214183412455312,"Lower":1.7046735063564862,"Upper":8.133040331267111},"Percentiles":{"P0":4.761295020580292,"P25":4.823743551969528,"P50":4.886192083358765,"P67":4.9619752168655396,"P80":5.019927024841309,"P85":5.042216181755066,"P90":5.064505338668823,"P95":5.086794495582581,"P100":5.109083652496338}},"Memory":{"Gen0Collections":1027,"Gen1Collections":0,"Gen2Collections":0,"TotalOperations":67108864,"BytesAllocatedPerOperation":96},"Measurements":[{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":238200},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":323700},{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":523400},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":563500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":1,"Operations":16,"Nanoseconds":2100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":2,"Operations":32,"Nanoseconds":1700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":3,"Operations":64,"Nanoseconds":8500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":4,"Operations":128,"Nanoseconds":17200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":5,"Operations":256,"Nanoseconds":14900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":6,"Operations":512,"Nanoseconds":26800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":7,"Operations":1024,"Nanoseconds":50000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":8,"Operations":2048,"Nanoseconds":91600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":9,"Operations":4096,"Nanoseconds":160600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":10,"Operations":8192,"Nanoseconds":257700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":11,"Operations":16384,"Nanoseconds":544700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":12,"Operations":32768,"Nanoseconds":2122000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":13,"Operations":65536,"Nanoseconds":2692500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":14,"Operations":131072,"Nanoseconds":2998200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":15,"Operations":262144,"Nanoseconds":4344800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":16,"Operations":524288,"Nanoseconds":8947800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":17,"Operations":1048576,"Nanoseconds":16919300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":18,"Operations":2097152,"Nanoseconds":33947800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":19,"Operations":4194304,"Nanoseconds":51342000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":20,"Operations":8388608,"Nanoseconds":83663400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":21,"Operations":16777216,"Nanoseconds":156282600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":22,"Operations":33554432,"Nanoseconds":299159100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":23,"Operations":67108864,"Nanoseconds":581289900},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":263497700},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":217357800},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":217888700},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":4,"Operations":67108864,"Nanoseconds":226521500},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":5,"Operations":67108864,"Nanoseconds":217011300},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":6,"Operations":67108864,"Nanoseconds":215025800},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":7,"Operations":67108864,"Nanoseconds":216084600},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":8,"Operations":67108864,"Nanoseconds":223948200},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":9,"Operations":67108864,"Nanoseconds":216067700},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":215835200},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":220909500},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":216488700},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":4,"Operations":67108864,"Nanoseconds":218144300},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":5,"Operations":67108864,"Nanoseconds":216317800},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":6,"Operations":67108864,"Nanoseconds":217359600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":7,"Operations":67108864,"Nanoseconds":218589300},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":8,"Operations":67108864,"Nanoseconds":220713500},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":9,"Operations":67108864,"Nanoseconds":218672300},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":10,"Operations":67108864,"Nanoseconds":216284400},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":11,"Operations":67108864,"Nanoseconds":217835500},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":12,"Operations":67108864,"Nanoseconds":222491900},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":13,"Operations":67108864,"Nanoseconds":218254100},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":14,"Operations":67108864,"Nanoseconds":219343500},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":15,"Operations":67108864,"Nanoseconds":213799200},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":577559600},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":561839700},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":561624900},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":561009100},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":546051100},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":537669400},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":342864800},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":327906800},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":319525100}],"Metrics":[{"Value":0.015303492546081543,"Descriptor":{"Id":"Gen0Collects","DisplayName":"Gen0","Legend":"GC Generation 0 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":0}},{"Value":0,"Descriptor":{"Id":"Gen1Collects","DisplayName":"Gen1","Legend":"GC Generation 1 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":1}},{"Value":0,"Descriptor":{"Id":"Gen2Collects","DisplayName":"Gen2","Legend":"GC Generation 2 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":2}},{"Value":96,"Descriptor":{"Id":"Allocated Memory","DisplayName":"Allocated","Legend":"Allocated memory per single operation (managed only, inclusive, 1KB = 1024B)","NumberFormat":"0.##","UnitType":2,"Unit":"B","TheGreaterTheBetter":false,"PriorityInCategory":3}}]},{"DisplayInfo":"EmptyModels.EmptyApiPathItem: ShortRun(IterationCount=3, LaunchCount=1, WarmupCount=3)","Namespace":"performance","Type":"EmptyModels","Method":"EmptyApiPathItem","MethodTitle":"EmptyApiPathItem","Parameters":"","FullName":"performance.EmptyModels.EmptyApiPathItem","HardwareIntrinsics":"AVX-512F+CD+BW+DQ+VL+VBMI,AES,BMI1,BMI2,FMA,LZCNT,PCLMUL,POPCNT VectorSize=256","Statistics":{"OriginalValues":[4.008521139621735,3.957848995923996,3.931517153978348],"N":3,"Min":3.931517153978348,"LowerFence":3.8869300857186317,"Q1":3.944683074951172,"Median":3.957848995923996,"Mean":3.9659624298413596,"Q3":3.9831850677728653,"UpperFence":4.040938057005405,"Max":4.008521139621735,"InterquartileRange":0.03850199282169342,"LowerOutliers":[],"UpperOutliers":[],"AllOutliers":[],"StandardError":0.022596270405314676,"Variance":0.0015317743086902997,"StandardDeviation":0.039137888403570006,"Skewness":0.19839496771764087,"Kurtosis":0.6666666666666639,"ConfidenceInterval":{"N":3,"Mean":3.9659624298413596,"StandardError":0.022596270405314676,"Level":12,"Margin":0.714020778872188,"Lower":3.2519416509691714,"Upper":4.679983208713548},"Percentiles":{"P0":3.931517153978348,"P25":3.944683074951172,"P50":3.957848995923996,"P67":3.975077524781227,"P80":3.988252282142639,"P85":3.993319496512413,"P90":3.998386710882187,"P95":4.003453925251961,"P100":4.008521139621735}},"Memory":{"Gen0Collections":1369,"Gen1Collections":0,"Gen2Collections":0,"TotalOperations":134217728,"BytesAllocatedPerOperation":64},"Measurements":[{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":219800},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":205400},{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":419500},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":402500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":1,"Operations":16,"Nanoseconds":2100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":2,"Operations":32,"Nanoseconds":3300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":3,"Operations":64,"Nanoseconds":15600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":4,"Operations":128,"Nanoseconds":24500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":5,"Operations":256,"Nanoseconds":30800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":6,"Operations":512,"Nanoseconds":18900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":7,"Operations":1024,"Nanoseconds":79700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":8,"Operations":2048,"Nanoseconds":66200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":9,"Operations":4096,"Nanoseconds":131800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":10,"Operations":8192,"Nanoseconds":271700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":11,"Operations":16384,"Nanoseconds":519100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":12,"Operations":32768,"Nanoseconds":1031300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":13,"Operations":65536,"Nanoseconds":1935400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":14,"Operations":131072,"Nanoseconds":3327700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":15,"Operations":262144,"Nanoseconds":4185000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":16,"Operations":524288,"Nanoseconds":7336300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":17,"Operations":1048576,"Nanoseconds":11045000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":18,"Operations":2097152,"Nanoseconds":24845600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":19,"Operations":4194304,"Nanoseconds":42702000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":20,"Operations":8388608,"Nanoseconds":88079700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":21,"Operations":16777216,"Nanoseconds":134018700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":22,"Operations":33554432,"Nanoseconds":242189100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":23,"Operations":67108864,"Nanoseconds":498484000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":24,"Operations":134217728,"Nanoseconds":993673000},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":475605800},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":437360600},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":430643400},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":4,"Operations":134217728,"Nanoseconds":443523100},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":5,"Operations":134217728,"Nanoseconds":436386400},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":6,"Operations":134217728,"Nanoseconds":428703600},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":7,"Operations":134217728,"Nanoseconds":429604400},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":8,"Operations":134217728,"Nanoseconds":433615100},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":9,"Operations":134217728,"Nanoseconds":427243600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":431567900},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":428252400},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":435031600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":4,"Operations":134217728,"Nanoseconds":428605200},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":5,"Operations":134217728,"Nanoseconds":437988000},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":6,"Operations":134217728,"Nanoseconds":430523600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":7,"Operations":134217728,"Nanoseconds":429658300},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":8,"Operations":134217728,"Nanoseconds":428328800},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":9,"Operations":134217728,"Nanoseconds":433577700},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":10,"Operations":134217728,"Nanoseconds":429664700},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":11,"Operations":134217728,"Nanoseconds":429691000},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":12,"Operations":134217728,"Nanoseconds":438015100},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":13,"Operations":134217728,"Nanoseconds":432642000},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":14,"Operations":134217728,"Nanoseconds":429105400},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":15,"Operations":134217728,"Nanoseconds":429570700},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":966033300},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":987708200},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":975237900},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":967705600},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":960904500},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":957370300},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":538014600},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":531213500},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":527679300}],"Metrics":[{"Value":0.01019984483718872,"Descriptor":{"Id":"Gen0Collects","DisplayName":"Gen0","Legend":"GC Generation 0 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":0}},{"Value":0,"Descriptor":{"Id":"Gen1Collects","DisplayName":"Gen1","Legend":"GC Generation 1 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":1}},{"Value":0,"Descriptor":{"Id":"Gen2Collects","DisplayName":"Gen2","Legend":"GC Generation 2 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":2}},{"Value":64,"Descriptor":{"Id":"Allocated Memory","DisplayName":"Allocated","Legend":"Allocated memory per single operation (managed only, inclusive, 1KB = 1024B)","NumberFormat":"0.##","UnitType":2,"Unit":"B","TheGreaterTheBetter":false,"PriorityInCategory":3}}]},{"DisplayInfo":"EmptyModels.EmptyApiPaths: ShortRun(IterationCount=3, LaunchCount=1, WarmupCount=3)","Namespace":"performance","Type":"EmptyModels","Method":"EmptyApiPaths","MethodTitle":"EmptyApiPaths","Parameters":"","FullName":"performance.EmptyModels.EmptyApiPaths","HardwareIntrinsics":"AVX-512F+CD+BW+DQ+VL+VBMI,AES,BMI1,BMI2,FMA,LZCNT,PCLMUL,POPCNT VectorSize=256","Statistics":{"OriginalValues":[56.19458556175232,58.00703763961792,54.46368455886841],"N":3,"Min":54.46368455886841,"LowerFence":52.67162024974823,"Q1":55.329135060310364,"Median":56.19458556175232,"Mean":56.22176925341288,"Q3":57.10081160068512,"UpperFence":59.75832641124725,"Max":58.00703763961792,"InterquartileRange":1.7716765403747559,"LowerOutliers":[],"UpperOutliers":[],"AllOutliers":[],"StandardError":1.0229682267033007,"Variance":3.139391978533486,"StandardDeviation":1.771832943178754,"Skewness":0.01533851892854978,"Kurtosis":0.6666666666666667,"ConfidenceInterval":{"N":3,"Mean":56.22176925341288,"StandardError":1.0229682267033007,"Level":12,"Margin":32.32482869475645,"Lower":23.896940558656432,"Upper":88.54659794816934},"Percentiles":{"P0":54.46368455886841,"P25":55.329135060310364,"P50":56.19458556175232,"P67":56.81081926822662,"P80":57.28205680847168,"P85":57.46330201625824,"P90":57.6445472240448,"P95":57.82579243183136,"P100":58.00703763961792}},"Memory":{"Gen0Collections":663,"Gen1Collections":0,"Gen2Collections":0,"TotalOperations":16777216,"BytesAllocatedPerOperation":248},"Measurements":[{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":207100},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":487800},{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":399100},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":431900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":1,"Operations":16,"Nanoseconds":32500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":2,"Operations":32,"Nanoseconds":29000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":3,"Operations":64,"Nanoseconds":49400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":4,"Operations":128,"Nanoseconds":45100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":5,"Operations":256,"Nanoseconds":62700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":6,"Operations":512,"Nanoseconds":108700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":7,"Operations":1024,"Nanoseconds":190000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":8,"Operations":2048,"Nanoseconds":376000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":9,"Operations":4096,"Nanoseconds":666100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":10,"Operations":8192,"Nanoseconds":1280100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":11,"Operations":16384,"Nanoseconds":3691500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":12,"Operations":32768,"Nanoseconds":4776300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":13,"Operations":65536,"Nanoseconds":7858300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":14,"Operations":131072,"Nanoseconds":14296200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":15,"Operations":262144,"Nanoseconds":33801700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":16,"Operations":524288,"Nanoseconds":51391300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":17,"Operations":1048576,"Nanoseconds":63122400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":18,"Operations":2097152,"Nanoseconds":108813900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":19,"Operations":4194304,"Nanoseconds":226965900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":20,"Operations":8388608,"Nanoseconds":457055600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":21,"Operations":16777216,"Nanoseconds":851060500},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":16777216,"Nanoseconds":64425900},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":16777216,"Nanoseconds":64339900},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":16777216,"Nanoseconds":65358800},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":4,"Operations":16777216,"Nanoseconds":57356600},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":5,"Operations":16777216,"Nanoseconds":53320700},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":6,"Operations":16777216,"Nanoseconds":54271500},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":7,"Operations":16777216,"Nanoseconds":52641100},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":16777216,"Nanoseconds":53390300},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":16777216,"Nanoseconds":51139900},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":16777216,"Nanoseconds":53221200},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":4,"Operations":16777216,"Nanoseconds":53972500},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":5,"Operations":16777216,"Nanoseconds":51805700},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":6,"Operations":16777216,"Nanoseconds":53551200},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":7,"Operations":16777216,"Nanoseconds":56244100},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":8,"Operations":16777216,"Nanoseconds":55057100},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":9,"Operations":16777216,"Nanoseconds":52491700},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":10,"Operations":16777216,"Nanoseconds":53081500},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":11,"Operations":16777216,"Nanoseconds":53212400},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":12,"Operations":16777216,"Nanoseconds":54112800},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":13,"Operations":16777216,"Nanoseconds":52742400},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":14,"Operations":16777216,"Nanoseconds":53494600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":15,"Operations":16777216,"Nanoseconds":52506900},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":16777216,"Nanoseconds":875679600},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":16777216,"Nanoseconds":874154500},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":16777216,"Nanoseconds":902579000},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":16777216,"Nanoseconds":996009900},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":16777216,"Nanoseconds":1026417800},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":16777216,"Nanoseconds":966970200},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":1,"Operations":16777216,"Nanoseconds":942788700},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":2,"Operations":16777216,"Nanoseconds":973196600},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":3,"Operations":16777216,"Nanoseconds":913749000}],"Metrics":[{"Value":0.039517879486083984,"Descriptor":{"Id":"Gen0Collects","DisplayName":"Gen0","Legend":"GC Generation 0 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":0}},{"Value":0,"Descriptor":{"Id":"Gen1Collects","DisplayName":"Gen1","Legend":"GC Generation 1 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":1}},{"Value":0,"Descriptor":{"Id":"Gen2Collects","DisplayName":"Gen2","Legend":"GC Generation 2 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":2}},{"Value":248,"Descriptor":{"Id":"Allocated Memory","DisplayName":"Allocated","Legend":"Allocated memory per single operation (managed only, inclusive, 1KB = 1024B)","NumberFormat":"0.##","UnitType":2,"Unit":"B","TheGreaterTheBetter":false,"PriorityInCategory":3}}]},{"DisplayInfo":"EmptyModels.EmptyApiRequestBody: ShortRun(IterationCount=3, LaunchCount=1, WarmupCount=3)","Namespace":"performance","Type":"EmptyModels","Method":"EmptyApiRequestBody","MethodTitle":"EmptyApiRequestBody","Parameters":"","FullName":"performance.EmptyModels.EmptyApiRequestBody","HardwareIntrinsics":"AVX-512F+CD+BW+DQ+VL+VBMI,AES,BMI1,BMI2,FMA,LZCNT,PCLMUL,POPCNT VectorSize=256","Statistics":{"OriginalValues":[3.822903335094452,3.573441505432129,3.65307480096817],"N":3,"Min":3.573441505432129,"LowerFence":3.4261617809534073,"Q1":3.6132581532001495,"Median":3.65307480096817,"Mean":3.6831398804982505,"Q3":3.737989068031311,"UpperFence":3.9250854402780533,"Max":3.822903335094452,"InterquartileRange":0.1247309148311615,"LowerOutliers":[],"UpperOutliers":[],"AllOutliers":[],"StandardError":0.07356569143738359,"Variance":0.016235732869980996,"StandardDeviation":0.12741951526348308,"Skewness":0.22281700510135516,"Kurtosis":0.6666666666666659,"ConfidenceInterval":{"N":3,"Mean":3.6831398804982505,"StandardError":0.07356569143738359,"Level":12,"Margin":2.32460628927671,"Lower":1.3585335912215406,"Upper":6.00774616977496},"Percentiles":{"P0":3.573441505432129,"P25":3.6132581532001495,"P50":3.65307480096817,"P67":3.710816502571106,"P80":3.754971921443939,"P85":3.7719547748565674,"P90":3.7889376282691956,"P95":3.8059204816818237,"P100":3.822903335094452}},"Memory":{"Gen0Collections":513,"Gen1Collections":0,"Gen2Collections":0,"TotalOperations":67108864,"BytesAllocatedPerOperation":48},"Measurements":[{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":350100},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":290700},{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":519100},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":417300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":1,"Operations":16,"Nanoseconds":2700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":2,"Operations":32,"Nanoseconds":2000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":3,"Operations":64,"Nanoseconds":2400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":4,"Operations":128,"Nanoseconds":12700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":5,"Operations":256,"Nanoseconds":17600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":6,"Operations":512,"Nanoseconds":27000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":7,"Operations":1024,"Nanoseconds":48100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":8,"Operations":2048,"Nanoseconds":111000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":9,"Operations":4096,"Nanoseconds":148700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":10,"Operations":8192,"Nanoseconds":203000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":11,"Operations":16384,"Nanoseconds":341900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":12,"Operations":32768,"Nanoseconds":982100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":13,"Operations":65536,"Nanoseconds":1560100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":14,"Operations":131072,"Nanoseconds":4326100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":15,"Operations":262144,"Nanoseconds":5036800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":16,"Operations":524288,"Nanoseconds":7322100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":17,"Operations":1048576,"Nanoseconds":15924900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":18,"Operations":2097152,"Nanoseconds":29285000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":19,"Operations":4194304,"Nanoseconds":55740600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":20,"Operations":8388608,"Nanoseconds":87921500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":21,"Operations":16777216,"Nanoseconds":132950200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":22,"Operations":33554432,"Nanoseconds":351226200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":23,"Operations":67108864,"Nanoseconds":667737300},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":259570400},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":218572700},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":215923400},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":4,"Operations":67108864,"Nanoseconds":216312100},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":5,"Operations":67108864,"Nanoseconds":216526100},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":6,"Operations":67108864,"Nanoseconds":220788100},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":7,"Operations":67108864,"Nanoseconds":222437900},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":8,"Operations":67108864,"Nanoseconds":225398700},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":9,"Operations":67108864,"Nanoseconds":214805700},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":10,"Operations":67108864,"Nanoseconds":219233600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":227975100},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":215417900},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":216518100},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":4,"Operations":67108864,"Nanoseconds":217749900},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":5,"Operations":67108864,"Nanoseconds":219227000},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":6,"Operations":67108864,"Nanoseconds":218258800},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":7,"Operations":67108864,"Nanoseconds":217233200},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":8,"Operations":67108864,"Nanoseconds":223391600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":9,"Operations":67108864,"Nanoseconds":222693000},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":10,"Operations":67108864,"Nanoseconds":215858900},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":11,"Operations":67108864,"Nanoseconds":216342100},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":12,"Operations":67108864,"Nanoseconds":216309600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":13,"Operations":67108864,"Nanoseconds":215176300},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":14,"Operations":67108864,"Nanoseconds":224367700},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":15,"Operations":67108864,"Nanoseconds":218670900},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":464698200},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":500291600},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":454809800},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":474300600},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":457559500},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":462903600},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":256550700},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":239809600},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":245153700}],"Metrics":[{"Value":0.007644295692443848,"Descriptor":{"Id":"Gen0Collects","DisplayName":"Gen0","Legend":"GC Generation 0 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":0}},{"Value":0,"Descriptor":{"Id":"Gen1Collects","DisplayName":"Gen1","Legend":"GC Generation 1 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":1}},{"Value":0,"Descriptor":{"Id":"Gen2Collects","DisplayName":"Gen2","Legend":"GC Generation 2 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":2}},{"Value":48,"Descriptor":{"Id":"Allocated Memory","DisplayName":"Allocated","Legend":"Allocated memory per single operation (managed only, inclusive, 1KB = 1024B)","NumberFormat":"0.##","UnitType":2,"Unit":"B","TheGreaterTheBetter":false,"PriorityInCategory":3}}]},{"DisplayInfo":"EmptyModels.EmptyApiResponse: ShortRun(IterationCount=3, LaunchCount=1, WarmupCount=3)","Namespace":"performance","Type":"EmptyModels","Method":"EmptyApiResponse","MethodTitle":"EmptyApiResponse","Parameters":"","FullName":"performance.EmptyModels.EmptyApiResponse","HardwareIntrinsics":"AVX-512F+CD+BW+DQ+VL+VBMI,AES,BMI1,BMI2,FMA,LZCNT,PCLMUL,POPCNT VectorSize=256","Statistics":{"OriginalValues":[3.8476988673210144,3.9207518100738525,3.8221731781959534],"N":3,"Min":3.8221731781959534,"LowerFence":3.7610020488500595,"Q1":3.834936022758484,"Median":3.8476988673210144,"Mean":3.86354128519694,"Q3":3.8842253386974335,"UpperFence":3.958159312605858,"Max":3.9207518100738525,"InterquartileRange":0.049289315938949585,"LowerOutliers":[],"UpperOutliers":[],"AllOutliers":[],"StandardError":0.02953908889841943,"Variance":0.0026176733188461774,"StandardDeviation":0.05116320278135623,"Skewness":0.27995606157548686,"Kurtosis":0.6666666666666698,"ConfidenceInterval":{"N":3,"Mean":3.86354128519694,"StandardError":0.02953908889841943,"Level":12,"Margin":0.9334072784623557,"Lower":2.9301340067345842,"Upper":4.796948563659296},"Percentiles":{"P0":3.8221731781959534,"P25":3.834936022758484,"P50":3.8476988673210144,"P67":3.8725368678569794,"P80":3.8915306329727173,"P85":3.898835927248001,"P90":3.906141221523285,"P95":3.9134465157985687,"P100":3.9207518100738525}},"Memory":{"Gen0Collections":1198,"Gen1Collections":0,"Gen2Collections":0,"TotalOperations":134217728,"BytesAllocatedPerOperation":56},"Measurements":[{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":376100},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":221900},{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":396800},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":368700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":1,"Operations":16,"Nanoseconds":2700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":2,"Operations":32,"Nanoseconds":3400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":3,"Operations":64,"Nanoseconds":3100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":4,"Operations":128,"Nanoseconds":13700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":5,"Operations":256,"Nanoseconds":19400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":6,"Operations":512,"Nanoseconds":21000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":7,"Operations":1024,"Nanoseconds":52700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":8,"Operations":2048,"Nanoseconds":70600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":9,"Operations":4096,"Nanoseconds":115200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":10,"Operations":8192,"Nanoseconds":243700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":11,"Operations":16384,"Nanoseconds":376200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":12,"Operations":32768,"Nanoseconds":755800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":13,"Operations":65536,"Nanoseconds":1498400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":14,"Operations":131072,"Nanoseconds":4973200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":15,"Operations":262144,"Nanoseconds":6039000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":16,"Operations":524288,"Nanoseconds":8600200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":17,"Operations":1048576,"Nanoseconds":19338900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":18,"Operations":2097152,"Nanoseconds":30191900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":19,"Operations":4194304,"Nanoseconds":48223900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":20,"Operations":8388608,"Nanoseconds":84187000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":21,"Operations":16777216,"Nanoseconds":126871200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":22,"Operations":33554432,"Nanoseconds":236210500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":23,"Operations":67108864,"Nanoseconds":486370100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":24,"Operations":134217728,"Nanoseconds":963129900},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":472097400},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":429518800},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":446969800},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":4,"Operations":134217728,"Nanoseconds":430317300},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":5,"Operations":134217728,"Nanoseconds":445237500},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":6,"Operations":134217728,"Nanoseconds":430254400},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":431369600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":434873600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":429149700},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":4,"Operations":134217728,"Nanoseconds":433410500},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":5,"Operations":134217728,"Nanoseconds":437448200},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":6,"Operations":134217728,"Nanoseconds":434905600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":7,"Operations":134217728,"Nanoseconds":429419900},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":8,"Operations":134217728,"Nanoseconds":435044700},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":9,"Operations":134217728,"Nanoseconds":429632300},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":10,"Operations":134217728,"Nanoseconds":430907100},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":11,"Operations":134217728,"Nanoseconds":429967300},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":12,"Operations":134217728,"Nanoseconds":433193300},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":13,"Operations":134217728,"Nanoseconds":438761700},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":14,"Operations":134217728,"Nanoseconds":425135800},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":15,"Operations":134217728,"Nanoseconds":431899900},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":962182800},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":939187400},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":934307200},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":948329300},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":958134300},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":944903300},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":516429400},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":526234400},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":513003400}],"Metrics":[{"Value":0.008925795555114746,"Descriptor":{"Id":"Gen0Collects","DisplayName":"Gen0","Legend":"GC Generation 0 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":0}},{"Value":0,"Descriptor":{"Id":"Gen1Collects","DisplayName":"Gen1","Legend":"GC Generation 1 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":1}},{"Value":0,"Descriptor":{"Id":"Gen2Collects","DisplayName":"Gen2","Legend":"GC Generation 2 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":2}},{"Value":56,"Descriptor":{"Id":"Allocated Memory","DisplayName":"Allocated","Legend":"Allocated memory per single operation (managed only, inclusive, 1KB = 1024B)","NumberFormat":"0.##","UnitType":2,"Unit":"B","TheGreaterTheBetter":false,"PriorityInCategory":3}}]},{"DisplayInfo":"EmptyModels.EmptyApiResponses: ShortRun(IterationCount=3, LaunchCount=1, WarmupCount=3)","Namespace":"performance","Type":"EmptyModels","Method":"EmptyApiResponses","MethodTitle":"EmptyApiResponses","Parameters":"","FullName":"performance.EmptyModels.EmptyApiResponses","HardwareIntrinsics":"AVX-512F+CD+BW+DQ+VL+VBMI,AES,BMI1,BMI2,FMA,LZCNT,PCLMUL,POPCNT VectorSize=256","Statistics":{"OriginalValues":[49.753642082214355,49.248212575912476,48.9742636680603],"N":3,"Min":48.9742636680603,"LowerFence":48.52670431137085,"Q1":49.11123812198639,"Median":49.248212575912476,"Mean":49.325372775395714,"Q3":49.500927329063416,"UpperFence":50.085461139678955,"Max":49.753642082214355,"InterquartileRange":0.38968920707702637,"LowerOutliers":[],"UpperOutliers":[],"AllOutliers":[],"StandardError":0.22827100151686744,"Variance":0.15632295040054106,"StandardDeviation":0.3953769725218466,"Skewness":0.18772333977799296,"Kurtosis":0.6666666666666623,"ConfidenceInterval":{"N":3,"Mean":49.325372775395714,"StandardError":0.22827100151686744,"Level":12,"Margin":7.21314780596149,"Lower":42.11222496943422,"Upper":56.538520581357204},"Percentiles":{"P0":48.9742636680603,"P25":49.11123812198639,"P50":49.248212575912476,"P67":49.420058608055115,"P80":49.5514702796936,"P85":49.60201323032379,"P90":49.65255618095398,"P95":49.70309913158417,"P100":49.753642082214355}},"Memory":{"Gen0Collections":663,"Gen1Collections":0,"Gen2Collections":0,"TotalOperations":16777216,"BytesAllocatedPerOperation":248},"Measurements":[{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":275400},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":508800},{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":376700},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":583100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":1,"Operations":16,"Nanoseconds":23800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":2,"Operations":32,"Nanoseconds":24400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":3,"Operations":64,"Nanoseconds":34800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":4,"Operations":128,"Nanoseconds":49800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":5,"Operations":256,"Nanoseconds":55300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":6,"Operations":512,"Nanoseconds":97500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":7,"Operations":1024,"Nanoseconds":226300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":8,"Operations":2048,"Nanoseconds":332400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":9,"Operations":4096,"Nanoseconds":763000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":10,"Operations":8192,"Nanoseconds":1263300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":11,"Operations":16384,"Nanoseconds":3763400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":12,"Operations":32768,"Nanoseconds":5111200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":13,"Operations":65536,"Nanoseconds":14678800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":14,"Operations":131072,"Nanoseconds":14982300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":15,"Operations":262144,"Nanoseconds":29102600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":16,"Operations":524288,"Nanoseconds":55318500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":17,"Operations":1048576,"Nanoseconds":81261900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":18,"Operations":2097152,"Nanoseconds":107289100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":19,"Operations":4194304,"Nanoseconds":211619300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":20,"Operations":8388608,"Nanoseconds":442216900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":21,"Operations":16777216,"Nanoseconds":877531400},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":16777216,"Nanoseconds":67251900},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":16777216,"Nanoseconds":65061700},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":16777216,"Nanoseconds":65932200},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":4,"Operations":16777216,"Nanoseconds":55004100},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":5,"Operations":16777216,"Nanoseconds":53159600},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":6,"Operations":16777216,"Nanoseconds":52655700},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":7,"Operations":16777216,"Nanoseconds":52698900},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":8,"Operations":16777216,"Nanoseconds":53889400},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":9,"Operations":16777216,"Nanoseconds":53188400},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":16777216,"Nanoseconds":52962700},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":16777216,"Nanoseconds":53773800},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":16777216,"Nanoseconds":52862900},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":4,"Operations":16777216,"Nanoseconds":52735600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":5,"Operations":16777216,"Nanoseconds":53759000},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":6,"Operations":16777216,"Nanoseconds":52709700},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":7,"Operations":16777216,"Nanoseconds":53116500},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":8,"Operations":16777216,"Nanoseconds":53430600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":9,"Operations":16777216,"Nanoseconds":54786400},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":10,"Operations":16777216,"Nanoseconds":55533900},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":11,"Operations":16777216,"Nanoseconds":53706300},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":12,"Operations":16777216,"Nanoseconds":54540000},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":13,"Operations":16777216,"Nanoseconds":55999000},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":14,"Operations":16777216,"Nanoseconds":54719700},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":15,"Operations":16777216,"Nanoseconds":56307100},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":16777216,"Nanoseconds":931949300},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":16777216,"Nanoseconds":870452000},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":16777216,"Nanoseconds":838819700},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":16777216,"Nanoseconds":888486600},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":16777216,"Nanoseconds":880006900},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":16777216,"Nanoseconds":875410800},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":1,"Operations":16777216,"Nanoseconds":834727600},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":2,"Operations":16777216,"Nanoseconds":826247900},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":3,"Operations":16777216,"Nanoseconds":821651800}],"Metrics":[{"Value":0.039517879486083984,"Descriptor":{"Id":"Gen0Collects","DisplayName":"Gen0","Legend":"GC Generation 0 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":0}},{"Value":0,"Descriptor":{"Id":"Gen1Collects","DisplayName":"Gen1","Legend":"GC Generation 1 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":1}},{"Value":0,"Descriptor":{"Id":"Gen2Collects","DisplayName":"Gen2","Legend":"GC Generation 2 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":2}},{"Value":248,"Descriptor":{"Id":"Allocated Memory","DisplayName":"Allocated","Legend":"Allocated memory per single operation (managed only, inclusive, 1KB = 1024B)","NumberFormat":"0.##","UnitType":2,"Unit":"B","TheGreaterTheBetter":false,"PriorityInCategory":3}}]},{"DisplayInfo":"EmptyModels.EmptyApiSchema: ShortRun(IterationCount=3, LaunchCount=1, WarmupCount=3)","Namespace":"performance","Type":"EmptyModels","Method":"EmptyApiSchema","MethodTitle":"EmptyApiSchema","Parameters":"","FullName":"performance.EmptyModels.EmptyApiSchema","HardwareIntrinsics":"AVX-512F+CD+BW+DQ+VL+VBMI,AES,BMI1,BMI2,FMA,LZCNT,PCLMUL,POPCNT VectorSize=256","Statistics":{"OriginalValues":[12.65668272972107,12.437400221824646,12.602367997169495],"N":3,"Min":12.437400221824646,"LowerFence":12.355422228574753,"Q1":12.51988410949707,"Median":12.602367997169495,"Mean":12.565483649571737,"Q3":12.629525363445282,"UpperFence":12.7939872443676,"Max":12.65668272972107,"InterquartileRange":0.10964125394821167,"LowerOutliers":[],"UpperOutliers":[],"AllOutliers":[],"StandardError":0.0659331628510277,"Variance":0.013041545890620416,"StandardDeviation":0.11419958796169281,"Skewness":-0.28928898309158113,"Kurtosis":0.666666666666673,"ConfidenceInterval":{"N":3,"Mean":12.565483649571737,"StandardError":0.0659331628510277,"Level":12,"Margin":2.08342560289617,"Lower":10.482058046675567,"Upper":14.648909252467908},"Percentiles":{"P0":12.437400221824646,"P25":12.51988410949707,"P50":12.602367997169495,"P67":12.62083500623703,"P80":12.63495683670044,"P85":12.640388309955597,"P90":12.645819783210754,"P95":12.651251256465912,"P100":12.65668272972107}},"Memory":{"Gen0Collections":2182,"Gen1Collections":0,"Gen2Collections":0,"TotalOperations":33554432,"BytesAllocatedPerOperation":408},"Measurements":[{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":238500},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":229100},{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":373900},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":415500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":1,"Operations":16,"Nanoseconds":7900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":2,"Operations":32,"Nanoseconds":14300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":3,"Operations":64,"Nanoseconds":29800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":4,"Operations":128,"Nanoseconds":33600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":5,"Operations":256,"Nanoseconds":64000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":6,"Operations":512,"Nanoseconds":107100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":7,"Operations":1024,"Nanoseconds":156900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":8,"Operations":2048,"Nanoseconds":247100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":9,"Operations":4096,"Nanoseconds":449100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":10,"Operations":8192,"Nanoseconds":971100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":11,"Operations":16384,"Nanoseconds":2005600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":12,"Operations":32768,"Nanoseconds":2038700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":13,"Operations":65536,"Nanoseconds":2127300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":14,"Operations":131072,"Nanoseconds":4273700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":15,"Operations":262144,"Nanoseconds":5796700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":16,"Operations":524288,"Nanoseconds":13355500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":17,"Operations":1048576,"Nanoseconds":21930800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":18,"Operations":2097152,"Nanoseconds":46202200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":19,"Operations":4194304,"Nanoseconds":85273500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":20,"Operations":8388608,"Nanoseconds":149395300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":21,"Operations":16777216,"Nanoseconds":285458700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":22,"Operations":33554432,"Nanoseconds":531523100},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":33554432,"Nanoseconds":128992600},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":33554432,"Nanoseconds":125204200},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":33554432,"Nanoseconds":105520800},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":4,"Operations":33554432,"Nanoseconds":106664900},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":5,"Operations":33554432,"Nanoseconds":105931600},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":6,"Operations":33554432,"Nanoseconds":107240900},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":7,"Operations":33554432,"Nanoseconds":106077000},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":33554432,"Nanoseconds":110776200},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":33554432,"Nanoseconds":109554700},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":33554432,"Nanoseconds":108492900},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":4,"Operations":33554432,"Nanoseconds":111087600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":5,"Operations":33554432,"Nanoseconds":107016800},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":6,"Operations":33554432,"Nanoseconds":106377200},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":7,"Operations":33554432,"Nanoseconds":107950500},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":8,"Operations":33554432,"Nanoseconds":105425500},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":9,"Operations":33554432,"Nanoseconds":107252200},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":10,"Operations":33554432,"Nanoseconds":105685200},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":11,"Operations":33554432,"Nanoseconds":107149400},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":12,"Operations":33554432,"Nanoseconds":108304000},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":13,"Operations":33554432,"Nanoseconds":110181800},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":14,"Operations":33554432,"Nanoseconds":109412300},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":15,"Operations":33554432,"Nanoseconds":107491600},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":33554432,"Nanoseconds":521511100},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":33554432,"Nanoseconds":541768300},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":33554432,"Nanoseconds":530953400},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":33554432,"Nanoseconds":532638300},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":33554432,"Nanoseconds":525280400},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":33554432,"Nanoseconds":530815800},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":1,"Operations":33554432,"Nanoseconds":424687800},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":2,"Operations":33554432,"Nanoseconds":417329900},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":3,"Operations":33554432,"Nanoseconds":422865300}],"Metrics":[{"Value":0.06502866744995117,"Descriptor":{"Id":"Gen0Collects","DisplayName":"Gen0","Legend":"GC Generation 0 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":0}},{"Value":0,"Descriptor":{"Id":"Gen1Collects","DisplayName":"Gen1","Legend":"GC Generation 1 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":1}},{"Value":0,"Descriptor":{"Id":"Gen2Collects","DisplayName":"Gen2","Legend":"GC Generation 2 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":2}},{"Value":408,"Descriptor":{"Id":"Allocated Memory","DisplayName":"Allocated","Legend":"Allocated memory per single operation (managed only, inclusive, 1KB = 1024B)","NumberFormat":"0.##","UnitType":2,"Unit":"B","TheGreaterTheBetter":false,"PriorityInCategory":3}}]},{"DisplayInfo":"EmptyModels.EmptyApiSecurityRequirement: ShortRun(IterationCount=3, LaunchCount=1, WarmupCount=3)","Namespace":"performance","Type":"EmptyModels","Method":"EmptyApiSecurityRequirement","MethodTitle":"EmptyApiSecurityRequirement","Parameters":"","FullName":"performance.EmptyModels.EmptyApiSecurityRequirement","HardwareIntrinsics":"AVX-512F+CD+BW+DQ+VL+VBMI,AES,BMI1,BMI2,FMA,LZCNT,PCLMUL,POPCNT VectorSize=256","Statistics":{"OriginalValues":[8.459033071994781,8.461305499076843,8.314041793346405],"N":3,"Min":8.314041793346405,"LowerFence":8.276089653372765,"Q1":8.386537432670593,"Median":8.459033071994781,"Mean":8.411460121472677,"Q3":8.460169285535812,"UpperFence":8.570617064833641,"Max":8.461305499076843,"InterquartileRange":0.07363185286521912,"LowerOutliers":[],"UpperOutliers":[],"AllOutliers":[],"StandardError":0.04871358117403967,"Variance":0.007119038972399258,"StandardDeviation":0.08437439761206747,"Skewness":-0.3845861095274997,"Kurtosis":0.6666666666666773,"ConfidenceInterval":{"N":3,"Mean":8.411460121472677,"StandardError":0.04871358117403967,"Level":12,"Margin":1.5393031039033973,"Lower":6.87215701756928,"Upper":9.950763225376075},"Percentiles":{"P0":8.314041793346405,"P25":8.386537432670593,"P50":8.459033071994781,"P67":8.459805697202682,"P80":8.460396528244019,"P85":8.460623770952225,"P90":8.460851013660431,"P95":8.461078256368637,"P100":8.461305499076843}},"Memory":{"Gen0Collections":1112,"Gen1Collections":0,"Gen2Collections":0,"TotalOperations":67108864,"BytesAllocatedPerOperation":104},"Measurements":[{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":303600},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":310600},{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":427000},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":394100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":1,"Operations":16,"Nanoseconds":2400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":2,"Operations":32,"Nanoseconds":2500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":3,"Operations":64,"Nanoseconds":17300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":4,"Operations":128,"Nanoseconds":51700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":5,"Operations":256,"Nanoseconds":29400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":6,"Operations":512,"Nanoseconds":156200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":7,"Operations":1024,"Nanoseconds":109100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":8,"Operations":2048,"Nanoseconds":146700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":9,"Operations":4096,"Nanoseconds":243500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":10,"Operations":8192,"Nanoseconds":499900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":11,"Operations":16384,"Nanoseconds":823800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":12,"Operations":32768,"Nanoseconds":1399100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":13,"Operations":65536,"Nanoseconds":2914700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":14,"Operations":131072,"Nanoseconds":4810000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":15,"Operations":262144,"Nanoseconds":5744000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":16,"Operations":524288,"Nanoseconds":11803900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":17,"Operations":1048576,"Nanoseconds":21860400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":18,"Operations":2097152,"Nanoseconds":45009300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":19,"Operations":4194304,"Nanoseconds":79225500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":20,"Operations":8388608,"Nanoseconds":104483400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":21,"Operations":16777216,"Nanoseconds":194473400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":22,"Operations":33554432,"Nanoseconds":416768100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":23,"Operations":67108864,"Nanoseconds":776063600},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":258658600},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":218740800},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":213408400},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":4,"Operations":67108864,"Nanoseconds":214845200},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":5,"Operations":67108864,"Nanoseconds":220606100},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":6,"Operations":67108864,"Nanoseconds":212854200},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":7,"Operations":67108864,"Nanoseconds":217540900},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":8,"Operations":67108864,"Nanoseconds":212317500},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":215006600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":215916700},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":221335700},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":4,"Operations":67108864,"Nanoseconds":211188600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":5,"Operations":67108864,"Nanoseconds":218576300},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":6,"Operations":67108864,"Nanoseconds":223132400},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":7,"Operations":67108864,"Nanoseconds":215318900},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":8,"Operations":67108864,"Nanoseconds":214230600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":9,"Operations":67108864,"Nanoseconds":215465700},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":10,"Operations":67108864,"Nanoseconds":214857100},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":11,"Operations":67108864,"Nanoseconds":217966600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":12,"Operations":67108864,"Nanoseconds":214298600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":13,"Operations":67108864,"Nanoseconds":215842400},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":14,"Operations":67108864,"Nanoseconds":222300100},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":15,"Operations":67108864,"Nanoseconds":220850600},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":798679400},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":770998700},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":797478000},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":783518500},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":783671000},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":773788300},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":567676100},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":567828600},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":557945900}],"Metrics":[{"Value":0.016570091247558594,"Descriptor":{"Id":"Gen0Collects","DisplayName":"Gen0","Legend":"GC Generation 0 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":0}},{"Value":0,"Descriptor":{"Id":"Gen1Collects","DisplayName":"Gen1","Legend":"GC Generation 1 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":1}},{"Value":0,"Descriptor":{"Id":"Gen2Collects","DisplayName":"Gen2","Legend":"GC Generation 2 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":2}},{"Value":104,"Descriptor":{"Id":"Allocated Memory","DisplayName":"Allocated","Legend":"Allocated memory per single operation (managed only, inclusive, 1KB = 1024B)","NumberFormat":"0.##","UnitType":2,"Unit":"B","TheGreaterTheBetter":false,"PriorityInCategory":3}}]},{"DisplayInfo":"EmptyModels.EmptyApiSecurityScheme: ShortRun(IterationCount=3, LaunchCount=1, WarmupCount=3)","Namespace":"performance","Type":"EmptyModels","Method":"EmptyApiSecurityScheme","MethodTitle":"EmptyApiSecurityScheme","Parameters":"","FullName":"performance.EmptyModels.EmptyApiSecurityScheme","HardwareIntrinsics":"AVX-512F+CD+BW+DQ+VL+VBMI,AES,BMI1,BMI2,FMA,LZCNT,PCLMUL,POPCNT VectorSize=256","Statistics":{"OriginalValues":[4.576227068901062,4.957868158817291,4.621759057044983],"N":3,"Min":4.576227068901062,"LowerFence":4.3127622455358505,"Q1":4.5989930629730225,"Median":4.621759057044983,"Mean":4.718618094921112,"Q3":4.789813607931137,"UpperFence":5.076044425368309,"Max":4.957868158817291,"InterquartileRange":0.19082054495811462,"LowerOutliers":[],"UpperOutliers":[],"AllOutliers":[],"StandardError":0.120344969832324,"Variance":0.04344873529182891,"StandardDeviation":0.20844360218492894,"Skewness":0.3643419038432841,"Kurtosis":0.6666666666666667,"ConfidenceInterval":{"N":3,"Mean":4.718618094921112,"StandardError":0.120344969832324,"Level":12,"Margin":3.802787254343326,"Lower":0.9158308405777862,"Upper":8.521405349264437},"Percentiles":{"P0":4.576227068901062,"P25":4.5989930629730225,"P50":4.621759057044983,"P67":4.736036151647568,"P80":4.823424518108368,"P85":4.857035428285599,"P90":4.89064633846283,"P95":4.92425724864006,"P100":4.957868158817291}},"Memory":{"Gen0Collections":941,"Gen1Collections":0,"Gen2Collections":0,"TotalOperations":67108864,"BytesAllocatedPerOperation":88},"Measurements":[{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":288800},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":245200},{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":389400},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":462600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":1,"Operations":16,"Nanoseconds":1600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":2,"Operations":32,"Nanoseconds":1400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":3,"Operations":64,"Nanoseconds":11800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":4,"Operations":128,"Nanoseconds":28000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":5,"Operations":256,"Nanoseconds":65900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":6,"Operations":512,"Nanoseconds":26300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":7,"Operations":1024,"Nanoseconds":61800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":8,"Operations":2048,"Nanoseconds":137000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":9,"Operations":4096,"Nanoseconds":276500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":10,"Operations":8192,"Nanoseconds":240500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":11,"Operations":16384,"Nanoseconds":720500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":12,"Operations":32768,"Nanoseconds":1316400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":13,"Operations":65536,"Nanoseconds":2183300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":14,"Operations":131072,"Nanoseconds":3779200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":15,"Operations":262144,"Nanoseconds":3678400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":16,"Operations":524288,"Nanoseconds":7920300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":17,"Operations":1048576,"Nanoseconds":14658500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":18,"Operations":2097152,"Nanoseconds":25661800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":19,"Operations":4194304,"Nanoseconds":45307500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":20,"Operations":8388608,"Nanoseconds":78128500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":21,"Operations":16777216,"Nanoseconds":148126500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":22,"Operations":33554432,"Nanoseconds":280903600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":23,"Operations":67108864,"Nanoseconds":531004500},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":255290900},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":218668700},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":219375000},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":4,"Operations":67108864,"Nanoseconds":224536400},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":5,"Operations":67108864,"Nanoseconds":216244200},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":6,"Operations":67108864,"Nanoseconds":231517300},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":7,"Operations":67108864,"Nanoseconds":222552400},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":216136600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":215453200},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":222429400},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":4,"Operations":67108864,"Nanoseconds":217643300},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":5,"Operations":67108864,"Nanoseconds":217037400},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":6,"Operations":67108864,"Nanoseconds":216408200},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":7,"Operations":67108864,"Nanoseconds":215079400},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":8,"Operations":67108864,"Nanoseconds":214794600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":9,"Operations":67108864,"Nanoseconds":215172800},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":10,"Operations":67108864,"Nanoseconds":216205000},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":11,"Operations":67108864,"Nanoseconds":215574500},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":12,"Operations":67108864,"Nanoseconds":218051200},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":13,"Operations":67108864,"Nanoseconds":221532700},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":14,"Operations":67108864,"Nanoseconds":224509000},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":15,"Operations":67108864,"Nanoseconds":223157600},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":550378600},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":526413500},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":534353500},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":523513600},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":549125100},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":526569200},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":1,"Operations":67108864,"Nanoseconds":307105400},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":2,"Operations":67108864,"Nanoseconds":332716900},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":3,"Operations":67108864,"Nanoseconds":310161000}],"Metrics":[{"Value":0.014021992683410645,"Descriptor":{"Id":"Gen0Collects","DisplayName":"Gen0","Legend":"GC Generation 0 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":0}},{"Value":0,"Descriptor":{"Id":"Gen1Collects","DisplayName":"Gen1","Legend":"GC Generation 1 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":1}},{"Value":0,"Descriptor":{"Id":"Gen2Collects","DisplayName":"Gen2","Legend":"GC Generation 2 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":2}},{"Value":88,"Descriptor":{"Id":"Allocated Memory","DisplayName":"Allocated","Legend":"Allocated memory per single operation (managed only, inclusive, 1KB = 1024B)","NumberFormat":"0.##","UnitType":2,"Unit":"B","TheGreaterTheBetter":false,"PriorityInCategory":3}}]},{"DisplayInfo":"EmptyModels.EmptyApiServer: ShortRun(IterationCount=3, LaunchCount=1, WarmupCount=3)","Namespace":"performance","Type":"EmptyModels","Method":"EmptyApiServer","MethodTitle":"EmptyApiServer","Parameters":"","FullName":"performance.EmptyModels.EmptyApiServer","HardwareIntrinsics":"AVX-512F+CD+BW+DQ+VL+VBMI,AES,BMI1,BMI2,FMA,LZCNT,PCLMUL,POPCNT VectorSize=256","Statistics":{"OriginalValues":[3.595738112926483,3.6468707025051117,3.636392205953598],"N":3,"Min":3.595738112926483,"LowerFence":3.577715717256069,"Q1":3.6160651594400406,"Median":3.636392205953598,"Mean":3.6263336737950644,"Q3":3.641631454229355,"UpperFence":3.6799808964133263,"Max":3.6468707025051117,"InterquartileRange":0.02556629478931427,"LowerOutliers":[],"UpperOutliers":[],"AllOutliers":[],"StandardError":0.01559397299324658,"Variance":0.000729515981142311,"StandardDeviation":0.02700955351616,"Skewness":-0.3207586837396803,"Kurtosis":0.6666666666666736,"ConfidenceInterval":{"N":3,"Mean":3.6263336737950644,"StandardError":0.01559397299324658,"Level":12,"Margin":0.49275480168315544,"Lower":3.133578872111909,"Upper":4.11908847547822},"Percentiles":{"P0":3.595738112926483,"P25":3.6160651594400406,"P50":3.636392205953598,"P67":3.6399548947811127,"P80":3.6426793038845062,"P85":3.6437271535396576,"P90":3.644775003194809,"P95":3.6458228528499603,"P100":3.6468707025051117}},"Memory":{"Gen0Collections":1026,"Gen1Collections":0,"Gen2Collections":0,"TotalOperations":134217728,"BytesAllocatedPerOperation":48},"Measurements":[{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":196300},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":247700},{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":543000},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":454900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":1,"Operations":16,"Nanoseconds":2300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":2,"Operations":32,"Nanoseconds":1500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":3,"Operations":64,"Nanoseconds":1700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":4,"Operations":128,"Nanoseconds":9300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":5,"Operations":256,"Nanoseconds":17100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":6,"Operations":512,"Nanoseconds":12700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":7,"Operations":1024,"Nanoseconds":39100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":8,"Operations":2048,"Nanoseconds":60100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":9,"Operations":4096,"Nanoseconds":103100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":10,"Operations":8192,"Nanoseconds":196200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":11,"Operations":16384,"Nanoseconds":332400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":12,"Operations":32768,"Nanoseconds":895300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":13,"Operations":65536,"Nanoseconds":1422800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":14,"Operations":131072,"Nanoseconds":3006000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":15,"Operations":262144,"Nanoseconds":4290700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":16,"Operations":524288,"Nanoseconds":8128600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":17,"Operations":1048576,"Nanoseconds":11937900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":18,"Operations":2097152,"Nanoseconds":25112900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":19,"Operations":4194304,"Nanoseconds":47334700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":20,"Operations":8388608,"Nanoseconds":73277300},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":21,"Operations":16777216,"Nanoseconds":120864200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":22,"Operations":33554432,"Nanoseconds":243271200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":23,"Operations":67108864,"Nanoseconds":490092700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":24,"Operations":134217728,"Nanoseconds":944482300},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":485037400},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":430131300},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":438048400},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":4,"Operations":134217728,"Nanoseconds":448079100},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":5,"Operations":134217728,"Nanoseconds":427465100},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":6,"Operations":134217728,"Nanoseconds":430005000},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":7,"Operations":134217728,"Nanoseconds":429945600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":433618500},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":430166000},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":430921000},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":4,"Operations":134217728,"Nanoseconds":430882200},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":5,"Operations":134217728,"Nanoseconds":427147000},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":6,"Operations":134217728,"Nanoseconds":429831100},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":7,"Operations":134217728,"Nanoseconds":431600000},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":8,"Operations":134217728,"Nanoseconds":438186900},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":9,"Operations":134217728,"Nanoseconds":434503900},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":10,"Operations":134217728,"Nanoseconds":427217600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":11,"Operations":134217728,"Nanoseconds":428965000},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":12,"Operations":134217728,"Nanoseconds":426373500},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":13,"Operations":134217728,"Nanoseconds":440523400},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":14,"Operations":134217728,"Nanoseconds":431144600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":15,"Operations":134217728,"Nanoseconds":429131000},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":935506000},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":915672100},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":1092088500},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":913494000},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":920356900},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":918950500},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":482611800},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":489474700},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":488068300}],"Metrics":[{"Value":0.007644295692443848,"Descriptor":{"Id":"Gen0Collects","DisplayName":"Gen0","Legend":"GC Generation 0 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":0}},{"Value":0,"Descriptor":{"Id":"Gen1Collects","DisplayName":"Gen1","Legend":"GC Generation 1 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":1}},{"Value":0,"Descriptor":{"Id":"Gen2Collects","DisplayName":"Gen2","Legend":"GC Generation 2 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":2}},{"Value":48,"Descriptor":{"Id":"Allocated Memory","DisplayName":"Allocated","Legend":"Allocated memory per single operation (managed only, inclusive, 1KB = 1024B)","NumberFormat":"0.##","UnitType":2,"Unit":"B","TheGreaterTheBetter":false,"PriorityInCategory":3}}]},{"DisplayInfo":"EmptyModels.EmptyApiServerVariable: ShortRun(IterationCount=3, LaunchCount=1, WarmupCount=3)","Namespace":"performance","Type":"EmptyModels","Method":"EmptyApiServerVariable","MethodTitle":"EmptyApiServerVariable","Parameters":"","FullName":"performance.EmptyModels.EmptyApiServerVariable","HardwareIntrinsics":"AVX-512F+CD+BW+DQ+VL+VBMI,AES,BMI1,BMI2,FMA,LZCNT,PCLMUL,POPCNT VectorSize=256","Statistics":{"OriginalValues":[3.5731248557567596,3.605746477842331,3.587469458580017],"N":3,"Min":3.5731248557567596,"LowerFence":3.55583094060421,"Q1":3.5802971571683884,"Median":3.587469458580017,"Mean":3.5887802640597024,"Q3":3.596607968211174,"UpperFence":3.6210741847753525,"Max":3.605746477842331,"InterquartileRange":0.016310811042785645,"LowerOutliers":[],"UpperOutliers":[],"AllOutliers":[],"StandardError":0.009439830774041771,"Variance":0.0002673312151276382,"StandardDeviation":0.01635026651549259,"Skewness":0.07965500576340336,"Kurtosis":0.6666666666666697,"ConfidenceInterval":{"N":3,"Mean":3.5887802640597024,"StandardError":0.009439830774041771,"Level":12,"Margin":0.29828972661424874,"Lower":3.2904905374454536,"Upper":3.887069990673951},"Percentiles":{"P0":3.5731248557567596,"P25":3.5802971571683884,"P50":3.587469458580017,"P67":3.593683645129204,"P80":3.5984356701374054,"P85":3.600263372063637,"P90":3.602091073989868,"P95":3.6039187759160995,"P100":3.605746477842331}},"Memory":{"Gen0Collections":1026,"Gen1Collections":0,"Gen2Collections":0,"TotalOperations":134217728,"BytesAllocatedPerOperation":48},"Measurements":[{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":371700},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":254400},{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":433700},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":375700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":1,"Operations":16,"Nanoseconds":1600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":2,"Operations":32,"Nanoseconds":1400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":3,"Operations":64,"Nanoseconds":1600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":4,"Operations":128,"Nanoseconds":9100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":5,"Operations":256,"Nanoseconds":13700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":6,"Operations":512,"Nanoseconds":18500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":7,"Operations":1024,"Nanoseconds":47400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":8,"Operations":2048,"Nanoseconds":80200},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":9,"Operations":4096,"Nanoseconds":140000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":10,"Operations":8192,"Nanoseconds":203900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":11,"Operations":16384,"Nanoseconds":319000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":12,"Operations":32768,"Nanoseconds":703600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":13,"Operations":65536,"Nanoseconds":1661100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":14,"Operations":131072,"Nanoseconds":2969800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":15,"Operations":262144,"Nanoseconds":5086000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":16,"Operations":524288,"Nanoseconds":6817400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":17,"Operations":1048576,"Nanoseconds":12464400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":18,"Operations":2097152,"Nanoseconds":26772100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":19,"Operations":4194304,"Nanoseconds":42402900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":20,"Operations":8388608,"Nanoseconds":64788600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":21,"Operations":16777216,"Nanoseconds":128199700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":22,"Operations":33554432,"Nanoseconds":229304600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":23,"Operations":67108864,"Nanoseconds":469170800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":24,"Operations":134217728,"Nanoseconds":1050158900},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":482862600},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":438063400},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":437736600},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":4,"Operations":134217728,"Nanoseconds":449224000},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":5,"Operations":134217728,"Nanoseconds":430870500},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":6,"Operations":134217728,"Nanoseconds":430880300},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":7,"Operations":134217728,"Nanoseconds":431059900},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":8,"Operations":134217728,"Nanoseconds":433814600},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":9,"Operations":134217728,"Nanoseconds":430888300},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":433063000},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":428459200},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":436361600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":4,"Operations":134217728,"Nanoseconds":431984900},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":5,"Operations":134217728,"Nanoseconds":440935600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":6,"Operations":134217728,"Nanoseconds":446692200},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":7,"Operations":134217728,"Nanoseconds":447435900},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":8,"Operations":134217728,"Nanoseconds":446514200},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":9,"Operations":134217728,"Nanoseconds":428894800},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":10,"Operations":134217728,"Nanoseconds":431177100},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":11,"Operations":134217728,"Nanoseconds":426843300},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":12,"Operations":134217728,"Nanoseconds":432199500},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":13,"Operations":134217728,"Nanoseconds":439803000},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":14,"Operations":134217728,"Nanoseconds":430739800},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":15,"Operations":134217728,"Nanoseconds":427542900},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":919068600},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":934330000},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":907260100},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":911776200},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":916154600},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":913701500},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":479576700},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":483955100},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":481502000}],"Metrics":[{"Value":0.007644295692443848,"Descriptor":{"Id":"Gen0Collects","DisplayName":"Gen0","Legend":"GC Generation 0 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":0}},{"Value":0,"Descriptor":{"Id":"Gen1Collects","DisplayName":"Gen1","Legend":"GC Generation 1 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":1}},{"Value":0,"Descriptor":{"Id":"Gen2Collects","DisplayName":"Gen2","Legend":"GC Generation 2 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":2}},{"Value":48,"Descriptor":{"Id":"Allocated Memory","DisplayName":"Allocated","Legend":"Allocated memory per single operation (managed only, inclusive, 1KB = 1024B)","NumberFormat":"0.##","UnitType":2,"Unit":"B","TheGreaterTheBetter":false,"PriorityInCategory":3}}]},{"DisplayInfo":"EmptyModels.EmptyApiTag: ShortRun(IterationCount=3, LaunchCount=1, WarmupCount=3)","Namespace":"performance","Type":"EmptyModels","Method":"EmptyApiTag","MethodTitle":"EmptyApiTag","Parameters":"","FullName":"performance.EmptyModels.EmptyApiTag","HardwareIntrinsics":"AVX-512F+CD+BW+DQ+VL+VBMI,AES,BMI1,BMI2,FMA,LZCNT,PCLMUL,POPCNT VectorSize=256","Statistics":{"OriginalValues":[4.337186366319656,3.7851549685001373,3.544905036687851],"N":3,"Min":3.544905036687851,"LowerFence":3.07081900537014,"Q1":3.665030002593994,"Median":3.7851549685001373,"Mean":3.8890821238358817,"Q3":4.061170667409897,"UpperFence":4.655381664633751,"Max":4.337186366319656,"InterquartileRange":0.3961406648159027,"LowerOutliers":[],"UpperOutliers":[],"AllOutliers":[],"StandardError":0.23454073315945237,"Variance":0.16502806653292032,"StandardDeviation":0.406236466276626,"Skewness":0.23908555244957305,"Kurtosis":0.6666666666666662,"ConfidenceInterval":{"N":3,"Mean":3.8890821238358817,"StandardError":0.23454073315945237,"Level":12,"Margin":7.411265397513464,"Lower":-3.5221832736775824,"Upper":11.300347521349346},"Percentiles":{"P0":3.544905036687851,"P25":3.665030002593994,"P50":3.7851549685001373,"P67":3.972845643758774,"P80":4.116373807191849,"P85":4.171576946973801,"P90":4.226780086755753,"P95":4.2819832265377045,"P100":4.337186366319656}},"Memory":{"Gen0Collections":1026,"Gen1Collections":0,"Gen2Collections":0,"TotalOperations":134217728,"BytesAllocatedPerOperation":48},"Measurements":[{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":230600},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":1,"Operations":1,"Nanoseconds":237500},{"IterationMode":"Overhead","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":562300},{"IterationMode":"Workload","IterationStage":"Jitting","LaunchIndex":1,"IterationIndex":2,"Operations":16,"Nanoseconds":768900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":1,"Operations":16,"Nanoseconds":2500},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":2,"Operations":32,"Nanoseconds":1800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":3,"Operations":64,"Nanoseconds":1400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":4,"Operations":128,"Nanoseconds":9600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":5,"Operations":256,"Nanoseconds":13900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":6,"Operations":512,"Nanoseconds":13000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":7,"Operations":1024,"Nanoseconds":34900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":8,"Operations":2048,"Nanoseconds":52800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":9,"Operations":4096,"Nanoseconds":117000},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":10,"Operations":8192,"Nanoseconds":198100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":11,"Operations":16384,"Nanoseconds":330800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":12,"Operations":32768,"Nanoseconds":677400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":13,"Operations":65536,"Nanoseconds":1347400},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":14,"Operations":131072,"Nanoseconds":3066100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":15,"Operations":262144,"Nanoseconds":4367600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":16,"Operations":524288,"Nanoseconds":7934600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":17,"Operations":1048576,"Nanoseconds":12963100},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":18,"Operations":2097152,"Nanoseconds":26865900},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":19,"Operations":4194304,"Nanoseconds":45149700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":20,"Operations":8388608,"Nanoseconds":63110800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":21,"Operations":16777216,"Nanoseconds":114926700},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":22,"Operations":33554432,"Nanoseconds":226123800},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":23,"Operations":67108864,"Nanoseconds":496236600},{"IterationMode":"Workload","IterationStage":"Pilot","LaunchIndex":1,"IterationIndex":24,"Operations":134217728,"Nanoseconds":938807200},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":467491900},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":438794300},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":426283700},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":4,"Operations":134217728,"Nanoseconds":429163500},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":5,"Operations":134217728,"Nanoseconds":427962300},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":6,"Operations":134217728,"Nanoseconds":432051700},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":7,"Operations":134217728,"Nanoseconds":444267900},{"IterationMode":"Overhead","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":8,"Operations":134217728,"Nanoseconds":429065600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":432656300},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":441570900},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":439881400},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":4,"Operations":134217728,"Nanoseconds":427733000},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":5,"Operations":134217728,"Nanoseconds":438916800},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":6,"Operations":134217728,"Nanoseconds":437055000},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":7,"Operations":134217728,"Nanoseconds":429268800},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":8,"Operations":134217728,"Nanoseconds":440088700},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":9,"Operations":134217728,"Nanoseconds":424824800},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":10,"Operations":134217728,"Nanoseconds":431891600},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":11,"Operations":134217728,"Nanoseconds":428195300},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":12,"Operations":134217728,"Nanoseconds":426285300},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":13,"Operations":134217728,"Nanoseconds":436099200},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":14,"Operations":134217728,"Nanoseconds":432594500},{"IterationMode":"Overhead","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":15,"Operations":134217728,"Nanoseconds":426596800},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":918455000},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":915878200},{"IterationMode":"Workload","IterationStage":"Warmup","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":976422200},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":1014721800},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":940629400},{"IterationMode":"Workload","IterationStage":"Actual","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":908383600},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":1,"Operations":134217728,"Nanoseconds":582127300},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":2,"Operations":134217728,"Nanoseconds":508034900},{"IterationMode":"Workload","IterationStage":"Result","LaunchIndex":1,"IterationIndex":3,"Operations":134217728,"Nanoseconds":475789100}],"Metrics":[{"Value":0.007644295692443848,"Descriptor":{"Id":"Gen0Collects","DisplayName":"Gen0","Legend":"GC Generation 0 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":0}},{"Value":0,"Descriptor":{"Id":"Gen1Collects","DisplayName":"Gen1","Legend":"GC Generation 1 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":1}},{"Value":0,"Descriptor":{"Id":"Gen2Collects","DisplayName":"Gen2","Legend":"GC Generation 2 collects per 1000 operations","NumberFormat":"#0.0000","UnitType":0,"Unit":"Count","TheGreaterTheBetter":false,"PriorityInCategory":2}},{"Value":48,"Descriptor":{"Id":"Allocated Memory","DisplayName":"Allocated","Legend":"Allocated memory per single operation (managed only, inclusive, 1KB = 1024B)","NumberFormat":"0.##","UnitType":2,"Unit":"B","TheGreaterTheBetter":false,"PriorityInCategory":3}}]}]} diff --git a/performance/benchmark/Descriptions.cs b/performance/benchmark/Descriptions.cs new file mode 100644 index 000000000..7f34575d3 --- /dev/null +++ b/performance/benchmark/Descriptions.cs @@ -0,0 +1,97 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Net.Http; +using System.Reflection; +using System.Threading.Tasks; +using BenchmarkDotNet.Attributes; +using Microsoft.OpenApi; +using Microsoft.OpenApi.Models; +using Microsoft.OpenApi.Reader; + +namespace performance; + +[MemoryDiagnoser] +[JsonExporter] +[ShortRunJob] +public class Descriptions +{ + [Benchmark] + public async Task PetStoreYaml() + { + return await ParseDocumentAsync(PetStoreYamlPath); + } + [Benchmark] + public async Task PetStoreJson() + { + return await ParseDocumentAsync(PetStoreJsonPath, OpenApiConstants.Json); + } + [Benchmark] + public async Task GHESYaml() + { + return await ParseDocumentAsync(GHESYamlDescriptionUrl); + } + [Benchmark] + public async Task GHESJson() + { + return await ParseDocumentAsync(GHESJsonDescriptionUrl, OpenApiConstants.Json); + } + private readonly Dictionary _streams = new(StringComparer.OrdinalIgnoreCase); + [GlobalSetup] + public async Task GetAllDescriptions() + { + _httpClient = new HttpClient(); + readerSettings = new OpenApiReaderSettings + { + LeaveStreamOpen = true, + }; + readerSettings.AddYamlReader(); + await LoadDocumentFromAssemblyIntoStreams(PetStoreYamlPath); + await LoadDocumentFromAssemblyIntoStreams(PetStoreJsonPath); + await LoadDocumentFromUrlIntoStreams(GHESYamlDescriptionUrl); + await LoadDocumentFromUrlIntoStreams(GHESJsonDescriptionUrl); + } + private OpenApiReaderSettings readerSettings; + private const string PetStoreYamlPath = @"petStore.yaml"; + private const string PetStoreJsonPath = @"petStore.json"; + private const string GHESYamlDescriptionUrl = @"https://raw.githubusercontent.com/github/rest-api-description/aef5e31a2d10fdaab311ec6d18a453021a81383d/descriptions/ghes-3.16/ghes-3.16.2022-11-28.yaml"; + private const string GHESJsonDescriptionUrl = @"https://raw.githubusercontent.com/github/rest-api-description/aef5e31a2d10fdaab311ec6d18a453021a81383d/descriptions/ghes-3.16/ghes-3.16.2022-11-28.json"; + private async Task ParseDocumentAsync(string fileName, string format = null) + { + format ??= OpenApiConstants.Yaml; + var stream = _streams[fileName]; + stream.Seek(0, SeekOrigin.Begin); + + var (document, _) = await OpenApiDocument.LoadAsync(stream, format, readerSettings).ConfigureAwait(false); + return document; + } + private HttpClient _httpClient; + private async Task LoadDocumentFromUrlIntoStreams(string url) + { + var response = await _httpClient.GetAsync(url).ConfigureAwait(false); + response.EnsureSuccessStatusCode(); + var stream = new MemoryStream(); // NOT disposed on purpose + await response.Content.CopyToAsync(stream).ConfigureAwait(false); + stream.Seek(0, SeekOrigin.Begin); + _streams.Add(url, stream); + } + private static readonly Assembly assembly = typeof(Descriptions).GetTypeInfo().Assembly; + private async Task LoadDocumentFromAssemblyIntoStreams(string fileName) + { + using var resource = assembly.GetManifestResourceStream($"PerformanceTests.{fileName}"); + var stream = new MemoryStream(); // NOT disposed on purpose + await resource.CopyToAsync(stream).ConfigureAwait(false); + stream.Seek(0, SeekOrigin.Begin); + _streams.Add(fileName, stream); + } + [GlobalCleanup] + public void Cleanup() + { + foreach (var stream in _streams.Values) + { + stream.Dispose(); + } + _streams.Clear(); + _httpClient.Dispose(); + } +} diff --git a/performance/benchmark/EmptyModels.cs b/performance/benchmark/EmptyModels.cs new file mode 100644 index 000000000..1e45ca7c8 --- /dev/null +++ b/performance/benchmark/EmptyModels.cs @@ -0,0 +1,153 @@ +using System; +using BenchmarkDotNet; +using BenchmarkDotNet.Attributes; +using Microsoft.OpenApi.Models; + +namespace performance; +[MemoryDiagnoser] +[JsonExporter] +[ShortRunJob] +// [SimpleJob(launchCount: 1, warmupCount: 30, iterationCount: 50, invocationCount:1000)] +public class EmptyModels +{ + [Benchmark] + public OpenApiCallback EmptyApiCallback() + { + return new OpenApiCallback(); + } + [Benchmark] + public OpenApiComponents EmptyApiComponents() + { + return new OpenApiComponents(); + } + [Benchmark] + public OpenApiContact EmptyApiContact() + { + return new OpenApiContact(); + } + [Benchmark] + public OpenApiDiscriminator EmptyApiDiscriminator() + { + return new OpenApiDiscriminator(); + } + [Benchmark] + public OpenApiDocument EmptyDocument() + { + return new OpenApiDocument(); + } + [Benchmark] + public OpenApiEncoding EmptyApiEncoding() + { + return new OpenApiEncoding(); + } + [Benchmark] + public OpenApiExample EmptyApiExample() + { + return new OpenApiExample(); + } + [Benchmark] + public OpenApiExternalDocs EmptyApiExternalDocs() + { + return new OpenApiExternalDocs(); + } + [Benchmark] + public OpenApiHeader EmptyApiHeader() + { + return new OpenApiHeader(); + } + [Benchmark] + public OpenApiInfo EmptyApiInfo() + { + return new OpenApiInfo(); + } + [Benchmark] + public OpenApiLicense EmptyApiLicense() + { + return new OpenApiLicense(); + } + [Benchmark] + public OpenApiLink EmptyApiLink() + { + return new OpenApiLink(); + } + [Benchmark] + public OpenApiMediaType EmptyApiMediaType() + { + return new OpenApiMediaType(); + } + [Benchmark] + public OpenApiOAuthFlow EmptyApiOAuthFlow() + { + return new OpenApiOAuthFlow(); + } + [Benchmark] + public OpenApiOAuthFlows EmptyApiOAuthFlows() + { + return new OpenApiOAuthFlows(); + } + [Benchmark] + public OpenApiOperation EmptyApiOperation() + { + return new OpenApiOperation(); + } + [Benchmark] + public OpenApiParameter EmptyApiParameter() + { + return new OpenApiParameter(); + } + [Benchmark] + public OpenApiPathItem EmptyApiPathItem() + { + return new OpenApiPathItem(); + } + [Benchmark] + public OpenApiPaths EmptyApiPaths() + { + return new OpenApiPaths(); + } + [Benchmark] + public OpenApiRequestBody EmptyApiRequestBody() + { + return new OpenApiRequestBody(); + } + [Benchmark] + public OpenApiResponse EmptyApiResponse() + { + return new OpenApiResponse(); + } + [Benchmark] + public OpenApiResponses EmptyApiResponses() + { + return new OpenApiResponses(); + } + [Benchmark] + public OpenApiSchema EmptyApiSchema() + { + return new OpenApiSchema(); + } + [Benchmark] + public OpenApiSecurityRequirement EmptyApiSecurityRequirement() + { + return new OpenApiSecurityRequirement(); + } + [Benchmark] + public OpenApiSecurityScheme EmptyApiSecurityScheme() + { + return new OpenApiSecurityScheme(); + } + [Benchmark] + public OpenApiServer EmptyApiServer() + { + return new OpenApiServer(); + } + [Benchmark] + public OpenApiServerVariable EmptyApiServerVariable() + { + return new OpenApiServerVariable(); + } + [Benchmark] + public OpenApiTag EmptyApiTag() + { + return new OpenApiTag(); + } +} diff --git a/performance/benchmark/PerformanceTests.csproj b/performance/benchmark/PerformanceTests.csproj new file mode 100644 index 000000000..acf59ce1d --- /dev/null +++ b/performance/benchmark/PerformanceTests.csproj @@ -0,0 +1,28 @@ + + + net8.0 + Exe + + + AnyCPU + pdbonly + true + true + true + Release + false + CA1822 + + + + + + + + + + + + + + \ No newline at end of file diff --git a/performance/benchmark/Program.cs b/performance/benchmark/Program.cs new file mode 100644 index 000000000..a745a2e6a --- /dev/null +++ b/performance/benchmark/Program.cs @@ -0,0 +1,13 @@ +using BenchmarkDotNet.Configs; +using BenchmarkDotNet.Running; + +namespace performance; +public class Program +{ + public static void Main(string[] args) + { + var config = DefaultConfig.Instance; + BenchmarkRunner.Run(config, args); + BenchmarkRunner.Run(config, args); + } +} diff --git a/performance/resultsComparer/Logger.cs b/performance/resultsComparer/Logger.cs new file mode 100644 index 000000000..974389517 --- /dev/null +++ b/performance/resultsComparer/Logger.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. + +using Microsoft.Extensions.Logging; + +namespace resultsComparer; +public static class Logger +{ + public static ILoggerFactory ConfigureLogger(LogLevel logLevel) + { + // Configure logger options +#if DEBUG + logLevel = logLevel > LogLevel.Debug ? LogLevel.Debug : logLevel; +#endif + + return LoggerFactory.Create((builder) => + { + builder + .AddSimpleConsole(c => c.IncludeScopes = true) +#if DEBUG + .AddDebug() +#endif + .SetMinimumLevel(logLevel); + }); + } +} diff --git a/performance/resultsComparer/Program.cs b/performance/resultsComparer/Program.cs new file mode 100644 index 000000000..1c6fb7bc2 --- /dev/null +++ b/performance/resultsComparer/Program.cs @@ -0,0 +1,47 @@ +// See https://aka.ms/new-console-template for more information +using System.CommandLine; +using Microsoft.Extensions.Logging; +using resultsComparer.Handlers; +using resultsComparer.Policies; + +namespace resultsComparer; + +public class Program +{ + public static async Task Main(string[] args) + { + var rootCommand = CreateRootCommand(); + return await rootCommand.InvokeAsync(args); + } + internal static RootCommand CreateRootCommand() + { + var rootCommand = new RootCommand { }; + + var compareCommand = new Command("compare") + { + Description = "Compare the benchmark results." + }; + var oldResultsPathArgument = new Argument("existingReportPath", () => ExistingReportPath, "The path to the existing benchmark report."); + compareCommand.AddArgument(oldResultsPathArgument); + var newResultsPathArgument = new Argument("newReportPath", () => ExistingReportPath, "The path to the new benchmark report."); + compareCommand.AddArgument(newResultsPathArgument); + var logLevelOption = new Option(["--log-level", "-l"], () => LogLevel.Warning, "The log level to use."); + compareCommand.AddOption(logLevelOption); + var allPolicyNames = IBenchmarkComparisonPolicy.GetAllPolicies().Select(static p => p.Name).Order(StringComparer.OrdinalIgnoreCase).ToArray(); + var policiesOption = new Option(["--policies", "-p"], () => ["all"], $"The policies to use for comparison: {string.Join(',', allPolicyNames)}.") + { + Arity = ArgumentArity.ZeroOrMore + }; + compareCommand.AddOption(policiesOption); + compareCommand.Handler = new CompareCommandHandler + { + OldResultsPath = oldResultsPathArgument, + NewResultsPath = newResultsPathArgument, + LogLevel = logLevelOption, + Policies = policiesOption, + }; + rootCommand.Add(compareCommand); + return rootCommand; + } + private const string ExistingReportPath = "../benchmark/BenchmarkDotNet.Artifacts/results/performance.EmptyModels-report.json"; +} diff --git a/performance/resultsComparer/handlers/AsyncCommandHandler.cs b/performance/resultsComparer/handlers/AsyncCommandHandler.cs new file mode 100644 index 000000000..f4c65b566 --- /dev/null +++ b/performance/resultsComparer/handlers/AsyncCommandHandler.cs @@ -0,0 +1,14 @@ +using System; +using System.CommandLine.Invocation; +using System.Threading.Tasks; + +namespace resultsComparer.Handlers; + +internal abstract class AsyncCommandHandler : ICommandHandler +{ + public int Invoke(InvocationContext context) + { + throw new InvalidOperationException("This method should not be called"); + } + public abstract Task InvokeAsync(InvocationContext context); +} diff --git a/performance/resultsComparer/handlers/CompareCommandHandler.cs b/performance/resultsComparer/handlers/CompareCommandHandler.cs new file mode 100644 index 000000000..ed079953e --- /dev/null +++ b/performance/resultsComparer/handlers/CompareCommandHandler.cs @@ -0,0 +1,96 @@ +using System; +using System.CommandLine; +using System.CommandLine.Invocation; +using System.Text.Json; +using System.Text.Json.Serialization; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using resultsComparer.Models; +using resultsComparer.Policies; + +namespace resultsComparer.Handlers; + +internal class CompareCommandHandler : AsyncCommandHandler +{ + public required Argument OldResultsPath { get; set; } + public required Argument NewResultsPath { get; set; } + public required Option LogLevel { get; set; } + public required Option Policies { get; set; } + + public override Task InvokeAsync(InvocationContext context) + { + var cancellationToken = context.BindingContext.GetRequiredService(); + var oldResultsPath = context.ParseResult.GetValueForArgument(OldResultsPath); + var newResultsPath = context.ParseResult.GetValueForArgument(NewResultsPath); + var policyNames = context.ParseResult.GetValueForOption(Policies) ?? []; + var policies = IBenchmarkComparisonPolicy.GetSelectedPolicies(policyNames).ToArray(); + var logLevel = context.ParseResult.GetValueForOption(LogLevel); + using var loggerFactory = Logger.ConfigureLogger(logLevel); + var logger = loggerFactory.CreateLogger(); + return CompareResultsAsync(oldResultsPath, newResultsPath, logger, policies, cancellationToken); + } + private static async Task CompareResultsAsync(string existingReportPath, string newReportPath, ILogger logger, IBenchmarkComparisonPolicy[] comparisonPolicies, CancellationToken cancellationToken = default) + { + + var existingBenchmark = await GetBenchmarksAllocatedBytes(existingReportPath, cancellationToken); + if (existingBenchmark is null) + { + logger.LogError("No existing benchmark data found."); + return 1; + } + var newBenchmark = await GetBenchmarksAllocatedBytes(newReportPath, cancellationToken); + if (newBenchmark is null) + { + logger.LogError("No new benchmark data found."); + return 1; + } + var hasErrors = false; + foreach (var existingBenchmarkResult in existingBenchmark) + { + if (!newBenchmark.TryGetValue(existingBenchmarkResult.Key, out var newBenchmarkResult)) + { + logger.LogError("No new benchmark result found for {ExistingBenchmarkResultKey}.", existingBenchmarkResult.Key); + hasErrors = true; + } + foreach (var comparisonPolicy in comparisonPolicies) + { + if (!comparisonPolicy.Equals(existingBenchmarkResult.Value, newBenchmarkResult)) + { + logger.LogError("Benchmark result for {ExistingBenchmarkResultKey} does not match the existing benchmark result. {ErrorMessage}", existingBenchmarkResult.Key, comparisonPolicy.GetErrorMessage(existingBenchmarkResult.Value, newBenchmarkResult)); + hasErrors = true; + } + } + } + + if (newBenchmark.Keys.Where(x => !existingBenchmark.ContainsKey(x)).ToArray() is { Length: > 0 } missingKeys) + { + logger.LogError("New benchmark results found that do not exist in the existing benchmark results."); + foreach (var missingKey in missingKeys) + { + logger.LogError("New benchmark result found: {MissingKey}.", missingKey); + } + hasErrors = true; + } + logger.LogInformation("Benchmark comparison complete. {Status}", hasErrors ? "Errors found" : "No errors found"); + return hasErrors ? 1 : 0; + } + + private static async Task?> GetBenchmarksAllocatedBytes(string targetPath, CancellationToken cancellationToken = default) + { + if (!File.Exists(targetPath)) + { + return null; + } + using var stream = new FileStream(targetPath, FileMode.Open, FileAccess.Read); + var report = (await JsonSerializer.DeserializeAsync(stream, BenchmarkSourceGenerationContext.Default.BenchmarkReport, cancellationToken: cancellationToken)) + ?? throw new InvalidOperationException($"Failed to deserialize {targetPath}."); + return report.Benchmarks + .Where(x => x.Memory is not null && x.Method is not null) + .ToDictionary(x => x.Method!, x => x.Memory!, StringComparer.OrdinalIgnoreCase); + } +} + +[JsonSerializable(typeof(BenchmarkReport))] +internal partial class BenchmarkSourceGenerationContext : JsonSerializerContext +{ +} diff --git a/performance/resultsComparer/models/BenchmarkReport.cs b/performance/resultsComparer/models/BenchmarkReport.cs new file mode 100644 index 000000000..c660619b6 --- /dev/null +++ b/performance/resultsComparer/models/BenchmarkReport.cs @@ -0,0 +1,21 @@ +using System.Text.Json.Serialization; + +namespace resultsComparer.Models; +internal sealed record BenchmarkReport +{ + [JsonPropertyName("Benchmarks")] + public Benchmark[] Benchmarks { get; init; } = []; +} +internal sealed record Benchmark +{ + [JsonPropertyName("Method")] + public string Method { get; init; } = string.Empty; + + [JsonPropertyName("Memory")] + public BenchmarkMemory Memory { get; init; } = new BenchmarkMemory(); +} +internal sealed record BenchmarkMemory +{ + [JsonPropertyName("BytesAllocatedPerOperation")] + public long AllocatedBytes { get; init; } +} diff --git a/performance/resultsComparer/policies/BaseBenchmarkComparisonPolicy.cs b/performance/resultsComparer/policies/BaseBenchmarkComparisonPolicy.cs new file mode 100644 index 000000000..86454b5c3 --- /dev/null +++ b/performance/resultsComparer/policies/BaseBenchmarkComparisonPolicy.cs @@ -0,0 +1,17 @@ +using resultsComparer.Models; + +namespace resultsComparer.Policies; + +internal abstract class BaseBenchmarkComparisonPolicy : IBenchmarkComparisonPolicy +{ + protected abstract string TypeName { get; } + public string Name => TypeName[..^6]; // Remove "Policy" suffix + + public abstract bool Equals(BenchmarkMemory? x, BenchmarkMemory? y); + public abstract string GetErrorMessage(BenchmarkMemory? x, BenchmarkMemory? y); + + public int GetHashCode(BenchmarkMemory obj) + { + throw new InvalidOperationException("This method should not be called. Use Equals instead."); + } +} diff --git a/performance/resultsComparer/policies/IBenchmarkComparisonPolicy.cs b/performance/resultsComparer/policies/IBenchmarkComparisonPolicy.cs new file mode 100644 index 000000000..6e3f518a1 --- /dev/null +++ b/performance/resultsComparer/policies/IBenchmarkComparisonPolicy.cs @@ -0,0 +1,40 @@ +using resultsComparer.Models; + +namespace resultsComparer.Policies; + +internal interface IBenchmarkComparisonPolicy : IEqualityComparer +{ + string GetErrorMessage(BenchmarkMemory? x, BenchmarkMemory? y); + string Name { get;} + public static IEnumerable GetSelectedPolicies(string[] names) + { + if (names is []) + { + yield break; + } + var allPolicies = GetAllPolicies(); + if (names is ["all"]) + { + foreach (var policy in allPolicies) + { + yield return policy; + } + } + var indexedNames = names.ToHashSet(StringComparer.OrdinalIgnoreCase); + foreach (var policy in allPolicies.Where(x => indexedNames.Contains(x.Name))) + { + yield return policy; + } + } + public static IBenchmarkComparisonPolicy[] GetAllPolicies() + { + return [ + IdenticalMemoryUsagePolicy.Instance, + ZeroPointOnePercentDifferenceMemoryUsagePolicy.Instance, + ZeroPointTwoPercentDifferenceMemoryUsagePolicy.Instance, + OnePercentDifferenceMemoryUsagePolicy.Instance, + TwoPercentDifferenceMemoryUsagePolicy.Instance, + FivePercentDifferenceMemoryUsagePolicy.Instance, + ]; + } +} diff --git a/performance/resultsComparer/policies/IdenticalMemoryUsagePolicy.cs b/performance/resultsComparer/policies/IdenticalMemoryUsagePolicy.cs new file mode 100644 index 000000000..fd5ab1fe4 --- /dev/null +++ b/performance/resultsComparer/policies/IdenticalMemoryUsagePolicy.cs @@ -0,0 +1,17 @@ +using resultsComparer.Models; + +namespace resultsComparer.Policies; +internal sealed class IdenticalMemoryUsagePolicy : BaseBenchmarkComparisonPolicy +{ + public static IdenticalMemoryUsagePolicy Instance { get; } = new IdenticalMemoryUsagePolicy(); + protected override string TypeName => nameof(IdenticalMemoryUsagePolicy); + public override bool Equals(BenchmarkMemory? x, BenchmarkMemory? y) + { + return x?.AllocatedBytes == y?.AllocatedBytes; + } + + public override string GetErrorMessage(BenchmarkMemory? x, BenchmarkMemory? y) + { + return $"Allocated bytes differ: {x?.AllocatedBytes} != {y?.AllocatedBytes}"; + } +} diff --git a/performance/resultsComparer/policies/PercentageMemoryUsagePolicy.cs b/performance/resultsComparer/policies/PercentageMemoryUsagePolicy.cs new file mode 100644 index 000000000..928bfa268 --- /dev/null +++ b/performance/resultsComparer/policies/PercentageMemoryUsagePolicy.cs @@ -0,0 +1,73 @@ +using resultsComparer.Models; + +namespace resultsComparer.Policies; + +internal sealed class ZeroPointOnePercentDifferenceMemoryUsagePolicy : PercentageMemoryUsagePolicy +{ + public static ZeroPointOnePercentDifferenceMemoryUsagePolicy Instance { get; } = new ZeroPointOnePercentDifferenceMemoryUsagePolicy(); + protected override string TypeName => nameof(ZeroPointOnePercentDifferenceMemoryUsagePolicy); + public ZeroPointOnePercentDifferenceMemoryUsagePolicy():base(0.1f) {} +} + +internal sealed class ZeroPointTwoPercentDifferenceMemoryUsagePolicy : PercentageMemoryUsagePolicy +{ + public static ZeroPointTwoPercentDifferenceMemoryUsagePolicy Instance { get; } = new ZeroPointTwoPercentDifferenceMemoryUsagePolicy(); + protected override string TypeName => nameof(ZeroPointTwoPercentDifferenceMemoryUsagePolicy); + public ZeroPointTwoPercentDifferenceMemoryUsagePolicy():base(0.2f) {} +} + +internal sealed class OnePercentDifferenceMemoryUsagePolicy : PercentageMemoryUsagePolicy +{ + public static OnePercentDifferenceMemoryUsagePolicy Instance { get; } = new OnePercentDifferenceMemoryUsagePolicy(); + protected override string TypeName => nameof(OnePercentDifferenceMemoryUsagePolicy); + public OnePercentDifferenceMemoryUsagePolicy():base(1) {} +} + +internal sealed class TwoPercentDifferenceMemoryUsagePolicy : PercentageMemoryUsagePolicy +{ + public static TwoPercentDifferenceMemoryUsagePolicy Instance { get; } = new TwoPercentDifferenceMemoryUsagePolicy(); + protected override string TypeName => nameof(TwoPercentDifferenceMemoryUsagePolicy); + public TwoPercentDifferenceMemoryUsagePolicy():base(2) {} +} + +internal sealed class FivePercentDifferenceMemoryUsagePolicy : PercentageMemoryUsagePolicy +{ + public static FivePercentDifferenceMemoryUsagePolicy Instance { get; } = new FivePercentDifferenceMemoryUsagePolicy(); + protected override string TypeName => nameof(FivePercentDifferenceMemoryUsagePolicy); + public FivePercentDifferenceMemoryUsagePolicy():base(1) {} +} + +internal abstract class PercentageMemoryUsagePolicy(float tolerancePercentagePoints) : BaseBenchmarkComparisonPolicy +{ + private float TolerancePercentagePoints { get; } = Math.Abs(tolerancePercentagePoints); + public override bool Equals(BenchmarkMemory? x, BenchmarkMemory? y) + { + if (x is null && y is null) + { + return true; + } + if (x is null || y is null) + { + return false; + } + var forwardRatio = GetPercentageDifference(x, y); + var backwardRatio = GetPercentageDifference(y, x); + return forwardRatio <= TolerancePercentagePoints && backwardRatio <= TolerancePercentagePoints; + } + private static double GetPercentageDifference(BenchmarkMemory x, BenchmarkMemory y) + { + return Math.Truncate(Math.Abs(GetAbsoluteRatio(x, y)) * 10000) / 100; + } + private static double GetAbsoluteRatio(BenchmarkMemory x, BenchmarkMemory y) + { + return Math.Abs(((double)(x.AllocatedBytes - y.AllocatedBytes))/x.AllocatedBytes); + } + public override string GetErrorMessage(BenchmarkMemory? x, BenchmarkMemory? y) + { + if (x is null || y is null) + { + return "One of the benchmarks is null."; + } + return $"Allocated bytes differ: {x.AllocatedBytes} != {y.AllocatedBytes}, Ratio: {GetAbsoluteRatio(x, y)}, Allowed: {TolerancePercentagePoints}%"; + } +} diff --git a/performance/resultsComparer/resultsComparer.csproj b/performance/resultsComparer/resultsComparer.csproj new file mode 100644 index 000000000..ac261848a --- /dev/null +++ b/performance/resultsComparer/resultsComparer.csproj @@ -0,0 +1,19 @@ + + + + Exe + net8.0 + enable + enable + + + + + + + + + + + + diff --git a/src/Microsoft.OpenApi/Reader/OpenApiModelFactory.cs b/src/Microsoft.OpenApi/Reader/OpenApiModelFactory.cs index dc206c47e..18d9eeb6b 100644 --- a/src/Microsoft.OpenApi/Reader/OpenApiModelFactory.cs +++ b/src/Microsoft.OpenApi/Reader/OpenApiModelFactory.cs @@ -118,30 +118,31 @@ public static async Task LoadAsync(Stream input, string? format = nu #endif settings ??= new OpenApiReaderSettings(); - Stream preparedStream; + Stream? preparedStream = null; if (format is null) { (preparedStream, format) = await PrepareStreamForReadingAsync(input, format, cancellationToken).ConfigureAwait(false); } - else - { - preparedStream = input; - } // Use StreamReader to process the prepared stream (buffered for YAML, direct for JSON) - using (preparedStream) + var result = await InternalLoadAsync(preparedStream ?? input, format, settings, cancellationToken).ConfigureAwait(false); + if (!settings.LeaveStreamOpen) { - var result = await InternalLoadAsync(preparedStream, format, settings, cancellationToken).ConfigureAwait(false); - if (!settings.LeaveStreamOpen) - { #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP || NET5_0_OR_GREATER - await input.DisposeAsync().ConfigureAwait(false); + await input.DisposeAsync().ConfigureAwait(false); #else - input.Dispose(); + input.Dispose(); #endif - } - return result; } + if (preparedStream is not null && preparedStream != input) + { +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP || NET5_0_OR_GREATER + await preparedStream.DisposeAsync().ConfigureAwait(false); +#else + preparedStream.Dispose(); +#endif + } + return result; } /// diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/Samples/OpenApiDocument/petStore.json b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/Samples/OpenApiDocument/petStore.json new file mode 100644 index 000000000..f316027dc --- /dev/null +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/Samples/OpenApiDocument/petStore.json @@ -0,0 +1,298 @@ +{ + "openapi": "3.0.0", + "info": { + "version": "1.0.0", + "title": "Swagger Petstore (Simple)", + "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification", + "termsOfService": "http://helloreverb.com/terms/", + "contact": { + "name": "Swagger API team", + "email": "foo@example.com", + "url": "http://swagger.io" + }, + "license": { + "name": "MIT", + "url": "http://opensource.org/licenses/MIT" + } + }, + "servers": [ + { + "url": "http://petstore.swagger.io/api" + } + ], + "paths": { + "/pets": { + "get": { + "description": "Returns all pets from the system that the user has access to", + "operationId": "findPets", + "parameters": [ + { + "name": "tags", + "in": "query", + "description": "tags to filter by", + "required": false, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + }, + { + "name": "limit", + "in": "query", + "description": "maximum number of results to return", + "required": false, + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "200": { + "description": "pet response", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet1" + } + } + }, + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet1" + } + } + } + } + }, + "4XX": { + "description": "unexpected client error", + "content": { + "text/html": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "content": { + "text/html": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + } + } + } + } + }, + "post": { + "description": "Creates a new pet in the store. Duplicates are allowed", + "operationId": "addPet", + "requestBody": { + "description": "Pet to add to the store", + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/newPet" + } + } + } + }, + "responses": { + "200": { + "description": "pet response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/pet1" + } + } + } + }, + "4XX": { + "description": "unexpected client error", + "content": { + "text/html": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "content": { + "text/html": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + } + } + } + } + } + }, + "/pets/{id}": { + "get": { + "description": "Returns a user based on a single ID, if the user does not have access to the pet", + "operationId": "findPetById", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "ID of pet to fetch", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "200": { + "description": "pet response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/pet1" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/pet1" + } + } + } + }, + "4XX": { + "description": "unexpected client error", + "content": { + "text/html": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "content": { + "text/html": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + } + } + } + } + }, + "delete": { + "description": "deletes a single pet based on the ID supplied", + "operationId": "deletePet", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "ID of pet to delete", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "204": { + "description": "pet deleted" + }, + "4XX": { + "description": "unexpected client error", + "content": { + "text/html": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "content": { + "text/html": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "pet1": { + "type": "object", + "required": [ + "id", + "name" + ], + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + }, + "newPet": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + }, + "errorModel": { + "type": "object", + "required": [ + "code", + "message" + ], + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } +} \ No newline at end of file From 2b159ad0e10cc8ef6f6ab4a8789a5251af378cc8 Mon Sep 17 00:00:00 2001 From: Rachit Malik Date: Fri, 11 Apr 2025 09:27:50 -0700 Subject: [PATCH 063/984] [DRAFT] 2.0 upgrade guide working doc (#2298) * added wip upgrade guide * made changes requested by vincent * modified folder structure * Fix typo Co-authored-by: Martin Costello * fix incorrect spacing Co-authored-by: Martin Costello * fix typo Co-authored-by: Martin Costello * fix typo Co-authored-by: Martin Costello * Update docs/upgrade-guide-2.md Co-authored-by: Martin Costello * fix typo Co-authored-by: Martin Costello * Update docs/upgrade-guide-2.md Co-authored-by: Martin Costello * Update docs/upgrade-guide-2.md Co-authored-by: Martin Costello * Update docs/upgrade-guide-2.md Co-authored-by: Martin Costello * Update docs/upgrade-guide-2.md Co-authored-by: Martin Costello * Update docs/upgrade-guide-2.md Co-authored-by: Martin Costello * Update docs/upgrade-guide-2.md Co-authored-by: Martin Costello * Apply suggestions from code review Co-authored-by: Martin Costello * chore: removes extraneous virtual keywords Signed-off-by: Vincent Biret * chore: fixes max/min types Signed-off-by: Vincent Biret * chore: updates comment on type change Signed-off-by: Vincent Biret * chore: updates annotation to metadata Signed-off-by: Vincent Biret * chore: linting Signed-off-by: Vincent Biret * docs: adds a snippet to document yaml reading Signed-off-by: Vincent Biret --------- Signed-off-by: Vincent Biret Co-authored-by: Rachit Malik Co-authored-by: Martin Costello Co-authored-by: Vincent Biret --- docs/upgrade-guide-2.md | 390 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 390 insertions(+) create mode 100644 docs/upgrade-guide-2.md diff --git a/docs/upgrade-guide-2.md b/docs/upgrade-guide-2.md new file mode 100644 index 000000000..7860a2434 --- /dev/null +++ b/docs/upgrade-guide-2.md @@ -0,0 +1,390 @@ +--- +title: Upgrade guide to OpenAPI.NET 2.1 +description: Learn how to upgrade your OpenAPI.NET version from 1.6 to 2.0 +author: rachit.malik +ms.author: malikrachit +ms.topic: conceptual +--- + +# Introduction + +We are excited to announce the preview of a new version of the OpenAPI.NET library! +OpenAPI.NET v2 is a major update to the OpenAPI.NET library. This release includes a number of performance improvements, API enhancements, and support for OpenAPI v3.1. + +## The biggest update ever + +Since the release of the first version of the OpenAPI.NET library in 2018, there has not been a major version update to the library. With the addition of support for OpenAPI v3.1 it was necessary to make some breaking changes. With this opportunity, we have taken the time to make some other improvements to the library, based on the experience we have gained supporting a large community of users for the last six years . + +## Performance Improvements + +One of the key features of OpenAPI.NET is its performance. This version makes it possible to parse JSON based OpenAPI descriptions even faster. OpenAPI.NET v1 relied on the excellent YamlSharp library for parsing both JSON and YAML files. With OpenAPI.NET v2 we are relying on System.Text.Json for parsing JSON files. For YAML files, we continue to use YamlSharp to parse YAML but then convert to JsonNodes for processing. This allows us to take advantage of the performance improvements in System.Text.Json while still supporting YAML files. + +In v1, instances of `$ref` were resolved in a second pass of the document to ensure the target of the reference has been parsed before attempting to resolve it. In v2, reference targets are lazily resolved when reference objects are accessed. This improves load time performance for documents that make heavy use of references. + +[How does this change the behaviour of external references?] + +## Reduced Dependencies + +In OpenAPI v1, it was necessary to include the Microsoft.OpenApi.Readers library to be able to read OpenAPI descriptions in either YAML or JSON. In OpenAPI.NET v2, the core Microsoft.OpenAPI library can both read and write JSON. It is only necessary to use the newly renamed [Microsoft.OpenApi.YamlReader](https://www.nuget.org/packages/Microsoft.OpenApi.YamlReader/) library if you need YAML support. This allows teams who are only working in JSON to avoid the additional dependency and therefore eliminate all non-.NET library references. + +Once the dependency is added, the reader needs to be added to the reader settings as demonstrated below + +```csharp +var settings = new OpenApiReaderSettings(); +settings.AddYamlReader(); + +var result = OpenApiDocument.LoadAsync(openApiString, settings: settings); +``` + +## API Enhancements + +The v1 library attempted to mimic the pattern of `XmlTextReader` and `JsonTextReader` for the purpose of loading OpenAPI documents from strings, streams and text readers. + +```csharp + var reader = new OpenApiStringReader(); + var openApiDoc = reader.Read(stringOpenApiDoc, out var diagnostic); +``` + +The same pattern can be used for `OpenApiStreamReader` and `OpenApiTextReader`. When we introduced the `ReadAsync` methods we eliminated the use of the `out` parameter. + +```csharp + var reader = new OpenApiStreamReader(); + var (document, diagnostics) = await reader.ReadAsync(streamOpenApiDoc); +``` + +A `ReadResult` object acts as a tuple of `OpenApiDocument` and `OpenApiDiagnostic`. + +The challenge with this approach is that the reader classes are not very discoverable and the behaviour is not actually consistent with the `*TextReader` pattern that allows incrementally reading the document. This library does not support incrementally reading the OpenAPI Document. It only reads a complete document and returns an `OpenApiDocument` instance. + +In the v2 library we are moving to the pattern used by classes like `XDocument` where a set of static `Load` and `Parse` methods are used as factory methods. + +```csharp +public class OpenApiDocument { + public static async Task LoadAsync(string url, OpenApiReaderSettings settings = null) {} + public static async Task LoadAsync(Stream stream, string? format = null, OpenApiReaderSettings? settings = null) {} + public static ReadResult Load(MemoryStream stream, string? format = null, OpenApiReaderSettings? settings = null) {} + public static ReadResult Parse(string input, string? format = null, OpenApiReaderSettings? settings = null) {} +} +``` + +This API design allows a developer to use IDE autocomplete to present all the loading options by simply knowing the name of the `OpenApiDocument` class. Each of these methods are layered on top of the more primitive methods to ensure consistent behaviour. + +As the YAML format is only supported when including the `Microsoft.OpenApi.YamlReader` library it was decided not to use an enum for the `format` parameter. We are considering implementing a more [strongly typed solution](https://github.com/microsoft/OpenAPI.NET/issues/1952) similar to the way that `HttpMethod` is implemented so that we have a strongly typed experience that is also extensible. + +When the loading methods are used without a format parameter, we will attempt to parse the document using the default JSON reader. If that fails and the YAML reader is registered, then we will attempt to read as YAML. The goal is always to provide the fastest path with JSON but still maintain the convenience of not having to care whether a URL points to YAML or JSON if you need that flexibility. + +### Removing the OpenAPI Any classes + +In the OpenAPI specification, there are a few properties that are defined as type `any`. This includes: + +- the example property in the parameter, media type objects +- the value property in the example object +- the values in the link object's parameters dictionary and `requestBody` property +- all `x-` extension properties + +In the v1 library, there are a set of classes that are derived from the `OpenApiAny` base class which is an abstract model which reflects the JSON data model plus some additional primitive types such as `decimal`, `float`, `datetime` etc. + +In v2 we are removing this abstraction and relying on the `JsonNode` model to represent these inner types. In v1 we were not able to reliably identify the additional primitive types and it caused a significant amount of false negatives in error reporting as well as incorrectly parsed data values. + +Due to `JsonNode` implicit operators, this makes initialization sometimes easier, instead of: + +```csharp + new OpenApiParameter + { + In = null, + Name = "username", + Description = "username to fetch", + Example = new OpenApiFloat(5), + }; +``` + +the assignment becomes simply, + +```csharp + Example = 0.5f, +``` + +For a more complex example, where the developer wants to create an extension that is an object they would do this in v1: + +```csharp + var openApiObject = new OpenApiObject + { + {"stringProp", new OpenApiString("stringValue1")}, + {"objProp", new OpenApiObject()}, + { + "arrayProp", + new OpenApiArray + { + new OpenApiBoolean(false) + } + } + }; + var parameter = new OpenApiParameter(); + parameter.Extensions.Add("x-foo", new OpenApiAny(openApiObject)); + +``` + +In v2, the equivalent code would be, + +```csharp + var openApiObject = new JsonObject + { + {"stringProp", "stringValue1"}, + {"objProp", new JsonObject()}, + { + "arrayProp", + new JsonArray + { + false + } + } + }; + var parameter = new OpenApiParameter(); + parameter.Extensions.Add("x-foo", new OpenApiAny(openApiObject)); + +``` + +### Updates to OpenApiSchema + +The OpenAPI 3.1 specification changes significantly how it leverages JSON Schema. In 3.0 and earlier, OpenAPI used a "subset, superset" of JSON Schema draft-4. This caused many problems for developers trying to use JSON Schema validation libraries with the JSON Schema in their OpenAPI descriptions. In OpenAPI 3.1, the 2020-12 draft version of JSON Schema was adopted and a new JSON Schema vocabulary was adopted to support OpenAPI specific keywords. All attempts to constrain what JSON Schema keywords could be used in OpenAPI were removed. + +#### New keywords introduced in 2020-12 + +```csharp + /// $schema, a JSON Schema dialect identifier. Value must be a URI + public string Schema { get; set; } + /// $id - Identifies a schema resource with its canonical URI. + public string Id { get; set; } + /// $comment - reserves a location for comments from schema authors to readers or maintainers of the schema. + public string Comment { get; set; } + /// $vocabulary- used in meta-schemas to identify the vocabularies available for use in schemas described by that meta-schema. + public IDictionary Vocabulary { get; set; } + /// $dynamicRef - an applicator that allows for deferring the full resolution until runtime, at which point it is resolved each time it is encountered while evaluating an instance + public string DynamicRef { get; set; } + /// $dynamicAnchor - used to create plain name fragments that are not tied to any particular structural location for referencing purposes, which are taken into consideration for dynamic referencing. + public string DynamicAnchor { get; set; } + /// $defs - reserves a location for schema authors to inline re-usable JSON Schemas into a more general schema. + public IDictionary Definitions { get; set; } + public IDictionary PatternProperties { get; set; } = new Dictionary(); + public bool UnevaluatedProperties { get; set;} + +``` + +#### Changes to existing keywords + +```csharp + + public string? ExclusiveMaximum { get; set; } // type changed to reflect the new version of JSON schema + public string? ExclusiveMinimum { get; set; } // type changed to reflect the new version of JSON schema + public JsonSchemaType? Type { get; set; } // Was string, now flagged enum + public string? Maximum { get; set; } // type changed to overcome double vs decimal issues + public string? Minimum { get; set; } // type changed to overcome double vs decimal issues + + public JsonNode Default { get; set; } // Type matching no longer enforced. Was IOpenApiAny + public bool ReadOnly { get; set; } // No longer has defined semantics in OpenAPI 3.1 + public bool WriteOnly { get; set; } // No longer has defined semantics in OpenAPI 3.1 + + public JsonNode Example { get; set; } // No longer IOpenApiAny + public IList Examples { get; set; } + public IList Enum { get; set; } + public OpenApiExternalDocs ExternalDocs { get; set; } // OpenApi Vocab + public bool Deprecated { get; set; } // OpenApi Vocab + public OpenApiXml Xml { get; set; } // OpenApi Vocab + + public IDictionary Metadata { get; set; } // Custom property bag to be used by the application, used to be named annotations +``` + +#### OpenApiSchema methods + +Other than the addition of `SerializeAsV31`, the methods have not changed. + +```csharp +public class OpenApiSchema : IOpenApiAnnotatable, IOpenApiExtensible, IOpenApiReferenceable, IOpenApiSerializable +{ + public OpenApiSchema() { } + public OpenApiSchema(OpenApiSchema schema) { } + public void SerializeAsV31(IOpenApiWriter writer) { } + public void SerializeAsV3(IOpenApiWriter writer) { } + public void SerializeAsV2(IOpenApiWriter writer) { } +} + +``` + +## OpenAPI v3.1 Support + +There are a number of new features in OpenAPI v3.1 that are now supported in OpenAPI.NET. + +### Webhooks + +```csharp + +public class OpenApiDocument : IOpenApiSerializable, IOpenApiExtensible, IOpenApiAnnotatable { + /// + /// The incoming webhooks that MAY be received as part of this API and that the API consumer MAY choose to implement. + /// A map of requests initiated other than by an API call, for example by an out of band registration. + /// The key name is a unique string to refer to each webhook, while the (optionally referenced) Path Item Object describes a request that may be initiated by the API provider and the expected responses + /// + public IDictionary? Webhooks { get; set; } = new Dictionary(); +} +``` + +### Summary in info object + +```csharp + + /// + /// Open API Info Object, it provides the metadata about the Open API. + /// + public class OpenApiInfo : IOpenApiSerializable, IOpenApiExtensible + { + /// + /// A short summary of the API. + /// + public string Summary { get; set; } + } +``` + +### License SPDX identifiers + +```csharp + /// + /// License Object. + /// + public class OpenApiLicense : IOpenApiSerializable, IOpenApiExtensible + { + /// + /// An SPDX license expression for the API. The identifier field is mutually exclusive of the Url property. + /// + public string Identifier { get; set; } + } +``` + +### Reusable path items + +```csharp + /// + /// Components Object. + /// + public class OpenApiComponents : IOpenApiSerializable, IOpenApiExtensible + { + /// + /// An object to hold reusable Object. + /// + public IDictionary? PathItems { get; set; } = new Dictionary(); + } +``` + +#### Summary and Description alongside $ref + +Through the use of proxy objects in order to represent references, it is now possible to set the Summary and Description property on an object that is a reference. This was previously not possible. + +```csharp + var parameter = new OpenApiParameterReference("id", hostdocument) + { + Description = "Customer Id" + }; +``` + +### Use HTTP Method Object Instead of Enum + +HTTP methods are now represented as objects instead of enums. This change enhances flexibility but requires updates to how HTTP methods are handled in your code. +Example: + +```csharp +// Before (1.6) +OpenApiOperation operation = new OpenApiOperation +{ + HttpMethod = OperationType.Get +}; + +// After (2.0) +OpenApiOperation operation = new OpenApiOperation +{ + HttpMethod = new HttpMethod("GET") // or HttpMethod.Get +}; +``` + +#### 2. Enable Null Reference Type Support + +Version 2.0 preview 13 introduces support for null reference types, which improves type safety and reduces the likelihood of null reference exceptions. + +**Example:** + +```csharp +// Before (1.6) +OpenApiDocument document = new OpenApiDocument +{ + Components = new OpenApiComponents() +}; + +// After (2.0) +OpenApiDocument document = new OpenApiDocument +{ + Components = new OpenApiComponents() + { + Schemas = new Dictionary() + } +}; + +``` + +#### 3. References as Components + +References can now be used as components, allowing for more modular and reusable OpenAPI documents. + +**Example:** + +```csharp +// Before (1.6) +OpenApiSchema schema = new OpenApiSchema +{ + Reference = new OpenApiReference + { + Type = ReferenceType.Schema, + Id = "MySchema" + } +}; + +// After (2.0) +OpenApiComponents components = new OpenApiComponents +{ + Schemas = new Dictionary + { + ["MySchema"] = new OpenApiSchema + { + Reference = new OpenApiSchemaReference("MySchema") + } + } +}; +``` + +### OpenApiDocument.SerializeAs() + +The `SerializeAs()` method simplifies serialization scenarios, making it easier to convert OpenAPI documents to different formats. +**Example:** + +```csharp +OpenApiDocument document = new OpenApiDocument(); +string json = document.SerializeAs(OpenApiSpecVersion.OpenApi3_0, OpenApiFormat.Json); + +``` + +### Bug Fixes + +## Serialization of References + +Fixed a bug where references would not serialize summary or descriptions in OpenAPI 3.1. +**Example:** + +```csharp +OpenApiSchemaReference schemaRef = new OpenApiSchemaReference("MySchema") +{ + Summary = "This is a summary", + Description = "This is a description" +}; +``` + +## Feedback + +If you have any feedback please file a GitHub issue [here](https://github.com/microsoft/OpenAPI.NET/issues) +The team is looking forward to hear your experience trying the new version and we hope you have fun busting out your OpenAPI 3.1 descriptions. From 74785231c8b894f3411cc4279c0279746f650870 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Fri, 11 Apr 2025 12:47:33 -0400 Subject: [PATCH 064/984] docs: adds the removed types from IOpenAny Signed-off-by: Vincent Biret --- docs/upgrade-guide-2.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/docs/upgrade-guide-2.md b/docs/upgrade-guide-2.md index 7860a2434..6c462f2ad 100644 --- a/docs/upgrade-guide-2.md +++ b/docs/upgrade-guide-2.md @@ -144,6 +144,28 @@ In v2, the equivalent code would be, ``` +> Note: as part of this change, the following types have been removed from the library: +> +> - AnyType +> - IOpenApiAny +> - OpenApiAnyCloneHelper +> - OpenApiArray +> - OpenApiBinary +> - OpenApiBoolean +> - OpenApiByte +> - OpenApiDate +> - OpenApiDateTime +> - OpenApiDouble +> - OpenApiFloat +> - OpenApiInteger +> - OpenApiLong +> - OpenApiNull +> - OpenApiObject +> - OpenApiPassword +> - OpenApiPrimitive +> - OpenApiString +> - PrimitiveType + ### Updates to OpenApiSchema The OpenAPI 3.1 specification changes significantly how it leverages JSON Schema. In 3.0 and earlier, OpenAPI used a "subset, superset" of JSON Schema draft-4. This caused many problems for developers trying to use JSON Schema validation libraries with the JSON Schema in their OpenAPI descriptions. In OpenAPI 3.1, the 2020-12 draft version of JSON Schema was adopted and a new JSON Schema vocabulary was adopted to support OpenAPI specific keywords. All attempts to constrain what JSON Schema keywords could be used in OpenAPI were removed. From deea642a5c9a1dd96b88243cdc353f3e3fb66f57 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Fri, 11 Apr 2025 12:51:52 -0400 Subject: [PATCH 065/984] docs: adds missing documentation around new exceptions Signed-off-by: Vincent Biret --- docs/upgrade-guide-2.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/upgrade-guide-2.md b/docs/upgrade-guide-2.md index 6c462f2ad..cb35ac99c 100644 --- a/docs/upgrade-guide-2.md +++ b/docs/upgrade-guide-2.md @@ -73,6 +73,13 @@ As the YAML format is only supported when including the `Microsoft.OpenApi.YamlR When the loading methods are used without a format parameter, we will attempt to parse the document using the default JSON reader. If that fails and the YAML reader is registered, then we will attempt to read as YAML. The goal is always to provide the fastest path with JSON but still maintain the convenience of not having to care whether a URL points to YAML or JSON if you need that flexibility. +### Additional exceptions + +While parsing an OpenAPI description, the library will now throw the following new exceptions: + +- `OpenApiReaderException` when the reader for the format cannot be found, the document cannot be parsed because it does not follow the format conventions, etc... +- `OpenApiUnsupportedSpecVersionException` when the document's version is not implemented by this version of the library and therefore cannot be parsed. + ### Removing the OpenAPI Any classes In the OpenAPI specification, there are a few properties that are defined as type `any`. This includes: From 7f3be25e20354fdf53fa5c35273d2d60c27993d4 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Fri, 11 Apr 2025 12:57:00 -0400 Subject: [PATCH 066/984] docs: adds information about async methods Signed-off-by: Vincent Biret --- docs/upgrade-guide-2.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/docs/upgrade-guide-2.md b/docs/upgrade-guide-2.md index cb35ac99c..34ca46cfc 100644 --- a/docs/upgrade-guide-2.md +++ b/docs/upgrade-guide-2.md @@ -23,6 +23,22 @@ In v1, instances of `$ref` were resolved in a second pass of the document to ens [How does this change the behaviour of external references?] +### Asynchronous API surface + +Any method which results in input/output access (memory, network, storage) is now Async and returns a `Task` to avoid any blocking calls an improve concurrency. + +For example: + +```csharp +var result = myOperation.SerializeAsJson(OpenApiSpecVersion.OpenApi2_0); +``` + +Is now: + +```csharp +var result = await myOperation.SerializeAsJsonAsync(OpenApiSpecVersion.OpenApi2_0); +``` + ## Reduced Dependencies In OpenAPI v1, it was necessary to include the Microsoft.OpenApi.Readers library to be able to read OpenAPI descriptions in either YAML or JSON. In OpenAPI.NET v2, the core Microsoft.OpenAPI library can both read and write JSON. It is only necessary to use the newly renamed [Microsoft.OpenApi.YamlReader](https://www.nuget.org/packages/Microsoft.OpenApi.YamlReader/) library if you need YAML support. This allows teams who are only working in JSON to avoid the additional dependency and therefore eliminate all non-.NET library references. From 305f0269a70568e61af3b58b560bbcd4c5f30c5b Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Fri, 11 Apr 2025 13:00:06 -0400 Subject: [PATCH 067/984] docs: adds information regarding trimming support Signed-off-by: Vincent Biret --- docs/upgrade-guide-2.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/upgrade-guide-2.md b/docs/upgrade-guide-2.md index 34ca46cfc..e3f797f9d 100644 --- a/docs/upgrade-guide-2.md +++ b/docs/upgrade-guide-2.md @@ -39,6 +39,14 @@ Is now: var result = await myOperation.SerializeAsJsonAsync(OpenApiSpecVersion.OpenApi2_0); ``` +### Trimming support + +To better support applications deployed in high performance environments or on devices which have limited compute available, any usage of reflection has been removed from the code base. This also brings support for trimming to the library. Any method relying on reflection has been removed or re-written. + +> Note: as part of this change, the following types have been removed: +> +> - StringExtensions + ## Reduced Dependencies In OpenAPI v1, it was necessary to include the Microsoft.OpenApi.Readers library to be able to read OpenAPI descriptions in either YAML or JSON. In OpenAPI.NET v2, the core Microsoft.OpenAPI library can both read and write JSON. It is only necessary to use the newly renamed [Microsoft.OpenApi.YamlReader](https://www.nuget.org/packages/Microsoft.OpenApi.YamlReader/) library if you need YAML support. This allows teams who are only working in JSON to avoid the additional dependency and therefore eliminate all non-.NET library references. From 4906d21f65f10f09b73fff2cbad6534facfdde72 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Fri, 11 Apr 2025 13:06:03 -0400 Subject: [PATCH 068/984] docs: adds information about the null collections Signed-off-by: Vincent Biret --- docs/upgrade-guide-2.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/docs/upgrade-guide-2.md b/docs/upgrade-guide-2.md index e3f797f9d..26c0f4e3a 100644 --- a/docs/upgrade-guide-2.md +++ b/docs/upgrade-guide-2.md @@ -47,6 +47,29 @@ To better support applications deployed in high performance environments or on d > > - StringExtensions +### Collections are not initialized + +To lower the memory footprint of the library, collections are now NOT initialized anymore when instantiating any of the models. + +Example + +```csharp +var mySchema = new OpenApiSchema(); + +// 1.6: works +// 2.X: if null reference types is enabled in the target application, +// this will lead to a warning or error at compile time. +// And fail at runtime with a null reference exception. +mySchema.AnyOf.Add(otherSchema); + +// one solution +mySchema.AnyOf ??= []; +mySchema.AnyOf.Add(otherSchema); + +// alternative +mySchema.AnyOf = [otherSchema]; +``` + ## Reduced Dependencies In OpenAPI v1, it was necessary to include the Microsoft.OpenApi.Readers library to be able to read OpenAPI descriptions in either YAML or JSON. In OpenAPI.NET v2, the core Microsoft.OpenAPI library can both read and write JSON. It is only necessary to use the newly renamed [Microsoft.OpenApi.YamlReader](https://www.nuget.org/packages/Microsoft.OpenApi.YamlReader/) library if you need YAML support. This allows teams who are only working in JSON to avoid the additional dependency and therefore eliminate all non-.NET library references. From d6a5fe419496b79c96b4e24d0fb58ff68c1a369b Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Fri, 11 Apr 2025 13:10:15 -0400 Subject: [PATCH 069/984] docs: revamps the null reference exception information Signed-off-by: Vincent Biret --- docs/upgrade-guide-2.md | 41 +++++++++++++++++------------------------ 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/docs/upgrade-guide-2.md b/docs/upgrade-guide-2.md index 26c0f4e3a..a83378770 100644 --- a/docs/upgrade-guide-2.md +++ b/docs/upgrade-guide-2.md @@ -220,6 +220,23 @@ In v2, the equivalent code would be, > - OpenApiString > - PrimitiveType +### Enable Null Reference Type Support + +Version 2.0 preview 13 introduces support for null reference types, which improves type safety and reduces the likelihood of null reference exceptions. + +**Example:** + +```csharp +var document = new OpenApiDocument +{ + Components = null +}; + +// 1.X: no compilation error or warning, but fails with a null reference exception at runtime +// 2.X: compilation error or warning depending on the project configuration +var componentA = document.Components["A"]; +``` + ### Updates to OpenApiSchema The OpenAPI 3.1 specification changes significantly how it leverages JSON Schema. In 3.0 and earlier, OpenAPI used a "subset, superset" of JSON Schema draft-4. This caused many problems for developers trying to use JSON Schema validation libraries with the JSON Schema in their OpenAPI descriptions. In OpenAPI 3.1, the 2020-12 draft version of JSON Schema was adopted and a new JSON Schema vocabulary was adopted to support OpenAPI specific keywords. All attempts to constrain what JSON Schema keywords could be used in OpenAPI were removed. @@ -380,30 +397,6 @@ OpenApiOperation operation = new OpenApiOperation }; ``` -#### 2. Enable Null Reference Type Support - -Version 2.0 preview 13 introduces support for null reference types, which improves type safety and reduces the likelihood of null reference exceptions. - -**Example:** - -```csharp -// Before (1.6) -OpenApiDocument document = new OpenApiDocument -{ - Components = new OpenApiComponents() -}; - -// After (2.0) -OpenApiDocument document = new OpenApiDocument -{ - Components = new OpenApiComponents() - { - Schemas = new Dictionary() - } -}; - -``` - #### 3. References as Components References can now be used as components, allowing for more modular and reusable OpenAPI documents. From 14c04d2e54bb7967fc6c72e60ae62d8599212e0e Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Fri, 11 Apr 2025 13:13:20 -0400 Subject: [PATCH 070/984] docs: adds information regarding collections types Signed-off-by: Vincent Biret --- docs/upgrade-guide-2.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/upgrade-guide-2.md b/docs/upgrade-guide-2.md index a83378770..0f3e2e62a 100644 --- a/docs/upgrade-guide-2.md +++ b/docs/upgrade-guide-2.md @@ -237,6 +237,19 @@ var document = new OpenApiDocument var componentA = document.Components["A"]; ``` +### Collections are implementations + +Any collection used by the model now documents using the implementation type instead of the interface. This facilitates the usage of new language features such as collections initialization. + +```csharp +var schema = new OpenApiSchema(); + +// 1.X: does not compile due to the lack of implementation type +// 2.X: compiles successfully +schema.AnyOf = []; +// now a List instead of IList +``` + ### Updates to OpenApiSchema The OpenAPI 3.1 specification changes significantly how it leverages JSON Schema. In 3.0 and earlier, OpenAPI used a "subset, superset" of JSON Schema draft-4. This caused many problems for developers trying to use JSON Schema validation libraries with the JSON Schema in their OpenAPI descriptions. In OpenAPI 3.1, the 2020-12 draft version of JSON Schema was adopted and a new JSON Schema vocabulary was adopted to support OpenAPI specific keywords. All attempts to constrain what JSON Schema keywords could be used in OpenAPI were removed. From e0e0448dac1286e23764cd82a1218733625337a0 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Fri, 11 Apr 2025 13:19:12 -0400 Subject: [PATCH 071/984] docs: adds change about annotations Signed-off-by: Vincent Biret --- docs/upgrade-guide-2.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/upgrade-guide-2.md b/docs/upgrade-guide-2.md index 0f3e2e62a..48ad76947 100644 --- a/docs/upgrade-guide-2.md +++ b/docs/upgrade-guide-2.md @@ -250,6 +250,19 @@ schema.AnyOf = []; // now a List instead of IList ``` +### Ephemeral object properties are now in Metadata + +In version 1.X applications could add ephemeral properties to some of the models from the libraries. These properties would be carried along in an "Annotations" property, but not serialized. This is especially helpful when building integrations that build document in multiple phases and need additional context to complete the work. The property is now named metadata to avoid any confusion with other terms. The parent interface has also been renamed from `IOpenApiAnnotatable` to `IMetadataContainer`. + +```csharp +var schema = new OpenApiSchema(); + +// 1.X +var info = schema.Annotations["foo"]; +// 2.X +var info = schema.Metadata["foo"]; +``` + ### Updates to OpenApiSchema The OpenAPI 3.1 specification changes significantly how it leverages JSON Schema. In 3.0 and earlier, OpenAPI used a "subset, superset" of JSON Schema draft-4. This caused many problems for developers trying to use JSON Schema validation libraries with the JSON Schema in their OpenAPI descriptions. In OpenAPI 3.1, the 2020-12 draft version of JSON Schema was adopted and a new JSON Schema vocabulary was adopted to support OpenAPI specific keywords. All attempts to constrain what JSON Schema keywords could be used in OpenAPI were removed. From 2f7cd057554f032315ee3894ff35586158abc4c3 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Fri, 11 Apr 2025 13:26:31 -0400 Subject: [PATCH 072/984] docs: add information about read result deconstruction Signed-off-by: Vincent Biret --- docs/upgrade-guide-2.md | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/docs/upgrade-guide-2.md b/docs/upgrade-guide-2.md index 48ad76947..e2f6e0e57 100644 --- a/docs/upgrade-guide-2.md +++ b/docs/upgrade-guide-2.md @@ -85,18 +85,24 @@ var result = OpenApiDocument.LoadAsync(openApiString, settings: settings); ## API Enhancements +### Loading the document + The v1 library attempted to mimic the pattern of `XmlTextReader` and `JsonTextReader` for the purpose of loading OpenAPI documents from strings, streams and text readers. ```csharp - var reader = new OpenApiStringReader(); - var openApiDoc = reader.Read(stringOpenApiDoc, out var diagnostic); +var reader = new OpenApiStringReader(); +var openApiDoc = reader.Read(stringOpenApiDoc, out var diagnostic); ``` -The same pattern can be used for `OpenApiStreamReader` and `OpenApiTextReader`. When we introduced the `ReadAsync` methods we eliminated the use of the `out` parameter. +The same pattern can be used for `OpenApiStreamReader` and `OpenApiTextReader`. When we introduced the `ReadAsync` methods we eliminated the use of the `out` parameter. To improve code readability, we've added deconstruction support to `ReadResult`. The properties also have been renamed to avoid confusion with their types. ```csharp - var reader = new OpenApiStreamReader(); - var (document, diagnostics) = await reader.ReadAsync(streamOpenApiDoc); +var reader = new OpenApiStreamReader(); +var (document, diagnostics) = await reader.ReadAsync(streamOpenApiDoc); +// or +var result = await reader.ReadAsync(streamOpenApiDoc); +var document = result.Document; +var diagnostics = result.Diagnostics; ``` A `ReadResult` object acts as a tuple of `OpenApiDocument` and `OpenApiDiagnostic`. From 6c1a630c8e4870e7adf987ac874555f329b8718d Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Fri, 11 Apr 2025 13:39:48 -0400 Subject: [PATCH 073/984] docs: adds follow up todos Signed-off-by: Vincent Biret --- docs/upgrade-guide-2.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/upgrade-guide-2.md b/docs/upgrade-guide-2.md index e2f6e0e57..6ff4a4395 100644 --- a/docs/upgrade-guide-2.md +++ b/docs/upgrade-guide-2.md @@ -489,3 +489,16 @@ OpenApiSchemaReference schemaRef = new OpenApiSchemaReference("MySchema") If you have any feedback please file a GitHub issue [here](https://github.com/microsoft/OpenAPI.NET/issues) The team is looking forward to hear your experience trying the new version and we hope you have fun busting out your OpenAPI 3.1 descriptions. + +## Todos + +- Models now have matching interfaces + reference type + type assertion pattern + reference fields removed from the base model + Target + RecursiveTarget + removed OpenApiReferenceResolver. +- Workspace + component resolution. +- Visitor and Validator method now pass the interface model. +- Removed all the IEffective/GetEffective infrastructure. +- OpenApiSchema.Type is now a flag enum + bitwise operations. +- JsonSchemaDialect + BaseUri in document. +- Copy constructors are gone, use shallow copy method. +- Multiple methods that should have been internal have been changed from public to private link OpenApiLink.SerializeAsV3WithoutReference. +- duplicated _style property on parameter was removed. +- ValidationRuleSet now accepts a key? \ No newline at end of file From b2bd4cd7ab27aafe65dfce96b76c3878aad29222 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Fri, 11 Apr 2025 13:42:34 -0400 Subject: [PATCH 074/984] chore: fixes indentation in code snippets Signed-off-by: Vincent Biret --- docs/upgrade-guide-2.md | 185 +++++++++++++++++++--------------------- 1 file changed, 88 insertions(+), 97 deletions(-) diff --git a/docs/upgrade-guide-2.md b/docs/upgrade-guide-2.md index 6ff4a4395..767209f22 100644 --- a/docs/upgrade-guide-2.md +++ b/docs/upgrade-guide-2.md @@ -149,58 +149,58 @@ In v2 we are removing this abstraction and relying on the `JsonNode` model to re Due to `JsonNode` implicit operators, this makes initialization sometimes easier, instead of: ```csharp - new OpenApiParameter - { - In = null, - Name = "username", - Description = "username to fetch", - Example = new OpenApiFloat(5), - }; +new OpenApiParameter +{ + In = null, + Name = "username", + Description = "username to fetch", + Example = new OpenApiFloat(5), +}; ``` the assignment becomes simply, ```csharp - Example = 0.5f, + Example = 0.5f, ``` For a more complex example, where the developer wants to create an extension that is an object they would do this in v1: ```csharp - var openApiObject = new OpenApiObject - { - {"stringProp", new OpenApiString("stringValue1")}, - {"objProp", new OpenApiObject()}, - { - "arrayProp", - new OpenApiArray - { - new OpenApiBoolean(false) - } - } - }; - var parameter = new OpenApiParameter(); - parameter.Extensions.Add("x-foo", new OpenApiAny(openApiObject)); +var openApiObject = new OpenApiObject +{ + {"stringProp", new OpenApiString("stringValue1")}, + {"objProp", new OpenApiObject()}, + { + "arrayProp", + new OpenApiArray + { + new OpenApiBoolean(false) + } + } +}; +var parameter = new OpenApiParameter(); +parameter.Extensions.Add("x-foo", new OpenApiAny(openApiObject)); ``` In v2, the equivalent code would be, ```csharp - var openApiObject = new JsonObject - { - {"stringProp", "stringValue1"}, - {"objProp", new JsonObject()}, - { - "arrayProp", - new JsonArray - { - false - } - } - }; - var parameter = new OpenApiParameter(); - parameter.Extensions.Add("x-foo", new OpenApiAny(openApiObject)); +var openApiObject = new JsonObject +{ + {"stringProp", "stringValue1"}, + {"objProp", new JsonObject()}, + { + "arrayProp", + new JsonArray + { + false + } + } +}; +var parameter = new OpenApiParameter(); +parameter.Extensions.Add("x-foo", new OpenApiAny(openApiObject)); ``` @@ -298,25 +298,24 @@ The OpenAPI 3.1 specification changes significantly how it leverages JSON Schema #### Changes to existing keywords ```csharp - - public string? ExclusiveMaximum { get; set; } // type changed to reflect the new version of JSON schema - public string? ExclusiveMinimum { get; set; } // type changed to reflect the new version of JSON schema - public JsonSchemaType? Type { get; set; } // Was string, now flagged enum - public string? Maximum { get; set; } // type changed to overcome double vs decimal issues - public string? Minimum { get; set; } // type changed to overcome double vs decimal issues - - public JsonNode Default { get; set; } // Type matching no longer enforced. Was IOpenApiAny - public bool ReadOnly { get; set; } // No longer has defined semantics in OpenAPI 3.1 - public bool WriteOnly { get; set; } // No longer has defined semantics in OpenAPI 3.1 - - public JsonNode Example { get; set; } // No longer IOpenApiAny - public IList Examples { get; set; } - public IList Enum { get; set; } - public OpenApiExternalDocs ExternalDocs { get; set; } // OpenApi Vocab - public bool Deprecated { get; set; } // OpenApi Vocab - public OpenApiXml Xml { get; set; } // OpenApi Vocab - - public IDictionary Metadata { get; set; } // Custom property bag to be used by the application, used to be named annotations +public string? ExclusiveMaximum { get; set; } // type changed to reflect the new version of JSON schema +public string? ExclusiveMinimum { get; set; } // type changed to reflect the new version of JSON schema +public JsonSchemaType? Type { get; set; } // Was string, now flagged enum +public string? Maximum { get; set; } // type changed to overcome double vs decimal issues +public string? Minimum { get; set; } // type changed to overcome double vs decimal issues + +public JsonNode Default { get; set; } // Type matching no longer enforced. Was IOpenApiAny +public bool ReadOnly { get; set; } // No longer has defined semantics in OpenAPI 3.1 +public bool WriteOnly { get; set; } // No longer has defined semantics in OpenAPI 3.1 + +public JsonNode Example { get; set; } // No longer IOpenApiAny +public IList Examples { get; set; } +public IList Enum { get; set; } +public OpenApiExternalDocs ExternalDocs { get; set; } // OpenApi Vocab +public bool Deprecated { get; set; } // OpenApi Vocab +public OpenApiXml Xml { get; set; } // OpenApi Vocab + +public IDictionary Metadata { get; set; } // Custom property bag to be used by the application, used to be named annotations ``` #### OpenApiSchema methods @@ -324,13 +323,13 @@ The OpenAPI 3.1 specification changes significantly how it leverages JSON Schema Other than the addition of `SerializeAsV31`, the methods have not changed. ```csharp -public class OpenApiSchema : IOpenApiAnnotatable, IOpenApiExtensible, IOpenApiReferenceable, IOpenApiSerializable +public class OpenApiSchema : IOpenApiMetadataContainer, IOpenApiExtensible, IOpenApiReferenceable, IOpenApiSerializable { - public OpenApiSchema() { } - public OpenApiSchema(OpenApiSchema schema) { } - public void SerializeAsV31(IOpenApiWriter writer) { } - public void SerializeAsV3(IOpenApiWriter writer) { } - public void SerializeAsV2(IOpenApiWriter writer) { } + public OpenApiSchema() { } + public OpenApiSchema(OpenApiSchema schema) { } + public void SerializeAsV31(IOpenApiWriter writer) { } + public void SerializeAsV3(IOpenApiWriter writer) { } + public void SerializeAsV2(IOpenApiWriter writer) { } } ``` @@ -343,60 +342,52 @@ There are a number of new features in OpenAPI v3.1 that are now supported in Ope ```csharp -public class OpenApiDocument : IOpenApiSerializable, IOpenApiExtensible, IOpenApiAnnotatable { - /// - /// The incoming webhooks that MAY be received as part of this API and that the API consumer MAY choose to implement. - /// A map of requests initiated other than by an API call, for example by an out of band registration. - /// The key name is a unique string to refer to each webhook, while the (optionally referenced) Path Item Object describes a request that may be initiated by the API provider and the expected responses - /// - public IDictionary? Webhooks { get; set; } = new Dictionary(); +public class OpenApiDocument : IOpenApiSerializable, IOpenApiExtensible, IOpenApiMetadataContainer +{ + public IDictionary? Webhooks { get; set; } = new Dictionary(); } ``` ### Summary in info object ```csharp - +public class OpenApiInfo : IOpenApiSerializable, IOpenApiExtensible +{ /// - /// Open API Info Object, it provides the metadata about the Open API. + /// A short summary of the API. /// - public class OpenApiInfo : IOpenApiSerializable, IOpenApiExtensible - { - /// - /// A short summary of the API. - /// - public string Summary { get; set; } - } + public string Summary { get; set; } +} ``` ### License SPDX identifiers ```csharp +/// +/// License Object. +/// +public class OpenApiLicense : IOpenApiSerializable, IOpenApiExtensible +{ /// - /// License Object. + /// An SPDX license expression for the API. The identifier field is mutually exclusive of the Url property. /// - public class OpenApiLicense : IOpenApiSerializable, IOpenApiExtensible - { - /// - /// An SPDX license expression for the API. The identifier field is mutually exclusive of the Url property. - /// - public string Identifier { get; set; } - } + public string Identifier { get; set; } +} ``` ### Reusable path items ```csharp +/// +/// Components Object. +/// +public class OpenApiComponents : IOpenApiSerializable, IOpenApiExtensible +{ /// - /// Components Object. + /// An object to hold reusable Object. /// - public class OpenApiComponents : IOpenApiSerializable, IOpenApiExtensible - { - /// - /// An object to hold reusable Object. - /// - public IDictionary? PathItems { get; set; } = new Dictionary(); - } + public IDictionary? PathItems { get; set; } = new Dictionary(); +} ``` #### Summary and Description alongside $ref @@ -404,10 +395,10 @@ public class OpenApiDocument : IOpenApiSerializable, IOpenApiExtensible, IOpenA Through the use of proxy objects in order to represent references, it is now possible to set the Summary and Description property on an object that is a reference. This was previously not possible. ```csharp - var parameter = new OpenApiParameterReference("id", hostdocument) - { - Description = "Customer Id" - }; +var parameter = new OpenApiParameterReference("id", hostdocument) +{ + Description = "Customer Id" +}; ``` ### Use HTTP Method Object Instead of Enum From 21f668714015dc1ecc93cde92989029650cd7b35 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Fri, 11 Apr 2025 13:43:57 -0400 Subject: [PATCH 075/984] chore: additional indenting Signed-off-by: Vincent Biret --- docs/upgrade-guide-2.md | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/docs/upgrade-guide-2.md b/docs/upgrade-guide-2.md index 767209f22..6c57054f5 100644 --- a/docs/upgrade-guide-2.md +++ b/docs/upgrade-guide-2.md @@ -276,22 +276,22 @@ The OpenAPI 3.1 specification changes significantly how it leverages JSON Schema #### New keywords introduced in 2020-12 ```csharp - /// $schema, a JSON Schema dialect identifier. Value must be a URI - public string Schema { get; set; } - /// $id - Identifies a schema resource with its canonical URI. - public string Id { get; set; } - /// $comment - reserves a location for comments from schema authors to readers or maintainers of the schema. - public string Comment { get; set; } - /// $vocabulary- used in meta-schemas to identify the vocabularies available for use in schemas described by that meta-schema. - public IDictionary Vocabulary { get; set; } - /// $dynamicRef - an applicator that allows for deferring the full resolution until runtime, at which point it is resolved each time it is encountered while evaluating an instance - public string DynamicRef { get; set; } - /// $dynamicAnchor - used to create plain name fragments that are not tied to any particular structural location for referencing purposes, which are taken into consideration for dynamic referencing. - public string DynamicAnchor { get; set; } - /// $defs - reserves a location for schema authors to inline re-usable JSON Schemas into a more general schema. - public IDictionary Definitions { get; set; } - public IDictionary PatternProperties { get; set; } = new Dictionary(); - public bool UnevaluatedProperties { get; set;} +/// $schema, a JSON Schema dialect identifier. Value must be a URI +public string Schema { get; set; } +/// $id - Identifies a schema resource with its canonical URI. +public string Id { get; set; } +/// $comment - reserves a location for comments from schema authors to readers or maintainers of the schema. +public string Comment { get; set; } +/// $vocabulary- used in meta-schemas to identify the vocabularies available for use in schemas described by that meta-schema. +public IDictionary Vocabulary { get; set; } +/// $dynamicRef - an applicator that allows for deferring the full resolution until runtime, at which point it is resolved each time it is encountered while evaluating an instance +public string DynamicRef { get; set; } +/// $dynamicAnchor - used to create plain name fragments that are not tied to any particular structural location for referencing purposes, which are taken into consideration for dynamic referencing. +public string DynamicAnchor { get; set; } +/// $defs - reserves a location for schema authors to inline re-usable JSON Schemas into a more general schema. +public IDictionary Definitions { get; set; } +public IDictionary PatternProperties { get; set; } = new Dictionary(); +public bool UnevaluatedProperties { get; set;} ``` From 55ef6dd5c99ad93883942ab73ab4ce96c105a9f5 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Fri, 11 Apr 2025 14:01:46 -0400 Subject: [PATCH 076/984] docs: adds test results Signed-off-by: Vincent Biret --- docs/upgrade-guide-2.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/docs/upgrade-guide-2.md b/docs/upgrade-guide-2.md index 6c57054f5..d3906921d 100644 --- a/docs/upgrade-guide-2.md +++ b/docs/upgrade-guide-2.md @@ -23,6 +23,29 @@ In v1, instances of `$ref` were resolved in a second pass of the document to ens [How does this change the behaviour of external references?] +### Results + +The following benchmark results outline an overall 50% reduction in processing time for the document parsing as well as 35% reduction in memory allocation when parsing JSON. +For YAML, the results between the different versions of the library are similar (some of the optimizations being compensated by the additional features). + +#### 1.X + +| Method | Mean | Error | StdDev | Gen0 | Gen1 | Gen2 | Allocated | +|------------- |---------------:|-------------:|-------------:|-----------:|-----------:|----------:|-------------:| +| PetStoreYaml | 448.7 μs | 326.6 μs | 17.90 μs | 58.5938 | 11.7188 | - | 381.79 KB | +| PetStoreJson | 484.8 μs | 156.9 μs | 8.60 μs | 62.5000 | 15.6250 | - | 389.28 KB | +| GHESYaml | 1,008,349.6 μs | 565,392.0 μs | 30,991.04 μs | 66000.0000 | 23000.0000 | 4000.0000 | 382785 KB | +| GHESJson | 1,039,447.0 μs | 267,501.0 μs | 14,662.63 μs | 67000.0000 | 23000.0000 | 4000.0000 | 389970.77 KB | + +#### 2.X + +| Method | Mean | Error | StdDev | Gen0 | Gen1 | Gen2 | Allocated | +|------------- |-------------:|--------------:|-------------:|-----------:|-----------:|----------:|-------------:| +| PetStoreYaml | 450.5 μs | 59.26 μs | 3.25 μs | 58.5938 | 11.7188 | - | 377.15 KB | +| PetStoreJson | 172.8 μs | 123.46 μs | 6.77 μs | 39.0625 | 7.8125 | - | 239.29 KB | +| GHESYaml | 943,452.7 μs | 137,685.49 μs | 7,547.01 μs | 66000.0000 | 21000.0000 | 3000.0000 | 389463.91 KB | +| GHESJson | 468,401.8 μs | 300,711.80 μs | 16,483.03 μs | 41000.0000 | 15000.0000 | 3000.0000 | 250934.62 KB | + ### Asynchronous API surface Any method which results in input/output access (memory, network, storage) is now Async and returns a `Task` to avoid any blocking calls an improve concurrency. From 83778c976b142c8912d90da092856e8ce00df2a2 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Fri, 11 Apr 2025 14:06:41 -0400 Subject: [PATCH 077/984] docs: fixes heading issues Signed-off-by: Vincent Biret --- docs/upgrade-guide-2.md | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/docs/upgrade-guide-2.md b/docs/upgrade-guide-2.md index d3906921d..4ed916dae 100644 --- a/docs/upgrade-guide-2.md +++ b/docs/upgrade-guide-2.md @@ -413,7 +413,7 @@ public class OpenApiComponents : IOpenApiSerializable, IOpenApiExtensible } ``` -#### Summary and Description alongside $ref +### Summary and Description alongside $ref Through the use of proxy objects in order to represent references, it is now possible to set the Summary and Description property on an object that is a reference. This was previously not possible. @@ -424,6 +424,13 @@ var parameter = new OpenApiParameterReference("id", hostdocument) }; ``` +Once serialized results in: + +```yaml +$ref: id +description: Customer Id +``` + ### Use HTTP Method Object Instead of Enum HTTP methods are now represented as objects instead of enums. This change enhances flexibility but requires updates to how HTTP methods are handled in your code. @@ -443,7 +450,7 @@ OpenApiOperation operation = new OpenApiOperation }; ``` -#### 3. References as Components +### References as Components References can now be used as components, allowing for more modular and reusable OpenAPI documents. @@ -465,9 +472,9 @@ OpenApiComponents components = new OpenApiComponents { Schemas = new Dictionary { - ["MySchema"] = new OpenApiSchema + ["MySchema"] = new OpenApiSchemaReference("MyOtherSchema") { - Reference = new OpenApiSchemaReference("MySchema") + Description = "Other reusable schema from initial schema" } } }; From 2272b87a21e9dc2d5b9568c1ba0a2d1af71eb065 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Fri, 11 Apr 2025 14:10:17 -0400 Subject: [PATCH 078/984] chore: adds a todo to document Signed-off-by: Vincent Biret --- docs/upgrade-guide-2.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/upgrade-guide-2.md b/docs/upgrade-guide-2.md index 4ed916dae..399daef44 100644 --- a/docs/upgrade-guide-2.md +++ b/docs/upgrade-guide-2.md @@ -522,4 +522,5 @@ The team is looking forward to hear your experience trying the new version and w - Copy constructors are gone, use shallow copy method. - Multiple methods that should have been internal have been changed from public to private link OpenApiLink.SerializeAsV3WithoutReference. - duplicated _style property on parameter was removed. +- discriminator now uses references. - ValidationRuleSet now accepts a key? \ No newline at end of file From 2a782477162590ae8651fccce6925ebf03e5a9a8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 11 Apr 2025 21:38:37 +0000 Subject: [PATCH 079/984] chore(deps): bump Microsoft.Extensions.DependencyInjection, Microsoft.Extensions.Logging, Microsoft.Extensions.Logging.Abstractions, Microsoft.Extensions.Logging.Console and System.Text.Json Bumps [Microsoft.Extensions.DependencyInjection](https://github.com/dotnet/runtime), [Microsoft.Extensions.Logging](https://github.com/dotnet/runtime), [Microsoft.Extensions.Logging.Abstractions](https://github.com/dotnet/runtime), [Microsoft.Extensions.Logging.Console](https://github.com/dotnet/runtime) and [System.Text.Json](https://github.com/dotnet/runtime). These dependencies needed to be updated together. Updates `Microsoft.Extensions.DependencyInjection` from 9.0.3 to 9.0.4 - [Release notes](https://github.com/dotnet/runtime/releases) - [Commits](https://github.com/dotnet/runtime/compare/v9.0.3...v9.0.4) Updates `Microsoft.Extensions.Logging` from 9.0.3 to 9.0.4 - [Release notes](https://github.com/dotnet/runtime/releases) - [Commits](https://github.com/dotnet/runtime/compare/v9.0.3...v9.0.4) Updates `Microsoft.Extensions.Logging.Abstractions` from 9.0.4 to 9.0.4 - [Release notes](https://github.com/dotnet/runtime/releases) - [Commits](https://github.com/dotnet/runtime/compare/v9.0.4...v9.0.4) Updates `Microsoft.Extensions.Logging.Console` from 9.0.3 to 9.0.4 - [Release notes](https://github.com/dotnet/runtime/releases) - [Commits](https://github.com/dotnet/runtime/compare/v9.0.3...v9.0.4) Updates `System.Text.Json` from 9.0.3 to 9.0.4 - [Release notes](https://github.com/dotnet/runtime/releases) - [Commits](https://github.com/dotnet/runtime/compare/v9.0.3...v9.0.4) --- updated-dependencies: - dependency-name: Microsoft.Extensions.DependencyInjection dependency-version: 9.0.4 dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: Microsoft.Extensions.Logging dependency-version: 9.0.4 dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: Microsoft.Extensions.Logging.Abstractions dependency-version: 9.0.4 dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: Microsoft.Extensions.Logging.Console dependency-version: 9.0.4 dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: System.Text.Json dependency-version: 9.0.4 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- performance/resultsComparer/resultsComparer.csproj | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/performance/resultsComparer/resultsComparer.csproj b/performance/resultsComparer/resultsComparer.csproj index ac261848a..c9b715c2d 100644 --- a/performance/resultsComparer/resultsComparer.csproj +++ b/performance/resultsComparer/resultsComparer.csproj @@ -1,4 +1,4 @@ - + Exe @@ -8,12 +8,12 @@ - - - + + + - + From b1fd77baac2ac33b341b1f66faf23daf47b0a99c Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Mon, 14 Apr 2025 08:24:38 -0400 Subject: [PATCH 080/984] Update docs/upgrade-guide-2.md Co-authored-by: Maggie Kimani --- docs/upgrade-guide-2.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/upgrade-guide-2.md b/docs/upgrade-guide-2.md index 399daef44..c1416b8fe 100644 --- a/docs/upgrade-guide-2.md +++ b/docs/upgrade-guide-2.md @@ -346,7 +346,7 @@ public IDictionary Metadata { get; set; } // Custom property ba Other than the addition of `SerializeAsV31`, the methods have not changed. ```csharp -public class OpenApiSchema : IOpenApiMetadataContainer, IOpenApiExtensible, IOpenApiReferenceable, IOpenApiSerializable +public class OpenApiSchema : IMetadataContainer, IOpenApiExtensible, IOpenApiReferenceable, IOpenApiSerializable { public OpenApiSchema() { } public OpenApiSchema(OpenApiSchema schema) { } From 653b79a6e51b62fd11c9308028e2947015f5ea98 Mon Sep 17 00:00:00 2001 From: Martin Costello Date: Mon, 14 Apr 2025 13:31:02 +0100 Subject: [PATCH 081/984] chore: Use Convert.ToHexString (#2322) * Use Convert.ToHexString Use `Convert.ToHexString()` when targeting .NET 8 instead of using a `StringBuilder`. * Update src/Microsoft.OpenApi/Models/OpenApiDocument.cs --------- Co-authored-by: Vincent Biret --- src/Microsoft.OpenApi/Models/OpenApiDocument.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs index 0f15a27d9..42273f729 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs @@ -544,6 +544,9 @@ private static string ConvertByteArrayToString(byte[] hash) { // Build the final string by converting each byte // into hex and appending it to a StringBuilder +#if NET5_0_OR_GREATER + return Convert.ToHexString(hash); +#else var sb = new StringBuilder(); for (var i = 0; i < hash.Length; i++) { @@ -551,6 +554,7 @@ private static string ConvertByteArrayToString(byte[] hash) } return sb.ToString(); +#endif } /// From 25136afa5a35160c75ab6e8bd297fbab479efd74 Mon Sep 17 00:00:00 2001 From: Martin Costello Date: Mon, 14 Apr 2025 13:42:32 +0100 Subject: [PATCH 082/984] chore: Use SHA512.HashDataAsync (#2324) * Use SHA512.HashDataAsync Use `SHA512.HashDataAsync()` for .NET 8 to reduce allocations. * Apply suggestions from code review * chore: uses 31 serialization method --------- Co-authored-by: Vincent Biret --- .../Models/OpenApiDocument.cs | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs index 42273f729..3b616f821 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs @@ -524,20 +524,35 @@ public void SetReferenceHostDocument() /// The hash value. public async Task GetHashCodeAsync(CancellationToken cancellationToken = default) { +#if NET7_OR_GREATER + using var memoryStream = new MemoryStream(); + using var streamWriter = new StreamWriter(memoryStream); + + await WriteDocumentAsync(streamWriter, cancellationToken).ConfigureAwait(false); + + memoryStream.Seek(0, SeekOrigin.Begin); + + var hash = await SHA512.HashDataAsync(memoryStream, cancellationToken).ConfigureAwait(false); +#else using HashAlgorithm sha = SHA512.Create(); using var cryptoStream = new CryptoStream(Stream.Null, sha, CryptoStreamMode.Write); using var streamWriter = new StreamWriter(cryptoStream); - var openApiJsonWriter = new OpenApiJsonWriter(streamWriter, new() { Terse = true }); - SerializeAsV3(openApiJsonWriter); - await openApiJsonWriter.FlushAsync(cancellationToken).ConfigureAwait(false); + await WriteDocumentAsync(streamWriter, cancellationToken).ConfigureAwait(false); -#if NET5_0_OR_GREATER - await cryptoStream.FlushFinalBlockAsync(cancellationToken).ConfigureAwait(false); -#else cryptoStream.FlushFinalBlock(); + + var hash = sha.Hash; #endif - return ConvertByteArrayToString(sha.Hash ?? []); + + return ConvertByteArrayToString(hash ?? []); + + async Task WriteDocumentAsync(TextWriter writer, CancellationToken token) + { + var openApiJsonWriter = new OpenApiJsonWriter(writer, new() { Terse = true }); + SerializeAsV31(openApiJsonWriter); + await openApiJsonWriter.FlushAsync(cancellationToken).ConfigureAwait(false); + } } private static string ConvertByteArrayToString(byte[] hash) From 5389c78c7fcbe775b2d113997674a009676cebc4 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Tue, 15 Apr 2025 15:04:21 +0300 Subject: [PATCH 083/984] chore: add test to validate DOM properties don't mutate on serialization --- .../OpenApiDocumentSerializationTests .cs | 71 ++++++++ .../OpenApiDocument/docWith31properties.json | 166 ++++++++++++++++++ 2 files changed, 237 insertions(+) create mode 100644 test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentSerializationTests .cs create mode 100644 test/Microsoft.OpenApi.Readers.Tests/V31Tests/Samples/OpenApiDocument/docWith31properties.json diff --git a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentSerializationTests .cs b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentSerializationTests .cs new file mode 100644 index 000000000..99f69168b --- /dev/null +++ b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentSerializationTests .cs @@ -0,0 +1,71 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Net.Http; +using System.Text.Json; +using System.Text.Json.Nodes; +using System.Text.Json.Serialization; +using System.Threading.Tasks; +using Microsoft.OpenApi.Models; +using Microsoft.OpenApi.Writers; +using Xunit; + +namespace Microsoft.OpenApi.Readers.Tests.V31Tests +{ + public class OpenApiDocumentSerializationTests + { + private const string SampleFolderPath = "V31Tests/Samples/OpenApiDocument/"; + + [Fact] + public async Task Serialize_DoesNotMutateDom() + { + // Arrange + var filePath = Path.Combine(SampleFolderPath, "docWith31properties.json"); + var (doc, _) = await OpenApiDocument.LoadAsync(filePath, SettingsFixture.ReaderSettings); + + // Act: Serialize using System.Text.Json + var options = new JsonSerializerOptions + { + Converters = + { + new HttpMethodOperationDictionaryConverter() + }, + }; + var originalSerialized = JsonSerializer.Serialize(doc, options); + Assert.NotNull(originalSerialized); // sanity check + + // Serialize using native OpenAPI writer + var jsonWriter = new StringWriter(); + var openApiWriter = new OpenApiJsonWriter(jsonWriter); + doc.SerializeAsV31(openApiWriter); + + // Serialize again with STJ after native writer serialization + var finalSerialized = JsonSerializer.Serialize(doc, options); + Assert.NotNull(finalSerialized); // sanity check + + // Assert: Ensure no mutation occurred in the DOM after native serialization + Assert.True(JsonNode.DeepEquals(originalSerialized, finalSerialized), "OpenAPI DOM was mutated by the native serializer."); + } + } + + public class HttpMethodOperationDictionaryConverter : JsonConverter> + { + public override Dictionary Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + throw new NotImplementedException(); + } + + public override void Write(Utf8JsonWriter writer, Dictionary value, JsonSerializerOptions options) + { + writer.WriteStartObject(); + + foreach (var kvp in value) + { + writer.WritePropertyName(kvp.Key.Method.ToLowerInvariant()); + JsonSerializer.Serialize(writer, kvp.Value, options); + } + + writer.WriteEndObject(); + } + } +} diff --git a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/Samples/OpenApiDocument/docWith31properties.json b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/Samples/OpenApiDocument/docWith31properties.json new file mode 100644 index 000000000..aabf7b10e --- /dev/null +++ b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/Samples/OpenApiDocument/docWith31properties.json @@ -0,0 +1,166 @@ +{ + "openapi": "3.1.1", + "info": { + "title": "Sample OpenAPI 3.1 API", + "description": "A sample API demonstrating OpenAPI 3.1 features", + "version": "2.0.0", + "summary": "Sample OpenAPI 3.1 API with the latest features", + "license": { + "name": "Apache 2.0", + "identifier": "Apache-2.0" + } + }, + "jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema", + "servers": [ + { + "url": "https://api.example.com/v2", + "description": "Main production server" + } + ], + "webhooks": { + "newPetAlert": { + "post": { + "summary": "Notify about a new pet being added", + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } + }, + "responses": { + "200": { + "description": "Webhook processed successfully" + } + } + } + } + }, + "paths": { + "/pets": { + "get": { + "summary": "List all pets", + "operationId": "listPets", + "parameters": [ + { + "name": "limit", + "in": "query", + "description": "How many items to return at one time (max 100)", + "required": false, + "schema": { + "type": "integer", + "exclusiveMinimum": 1, + "exclusiveMaximum": 100 + } + } + ], + "responses": { + "200": { + "description": "A paged array of pets", + "content": { + "application/json": { + "schema": { + "$ref": "https://example.com/schemas/pet.json" + } + } + } + } + } + } + }, + "/sample": { + "get": { + "summary": "Sample endpoint", + "responses": { + "200": { + "description": "Sample response", + "content": { + "application/json": { + "schema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://example.com/schemas/person.schema.yaml", + "$comment": "A schema defining a pet object with optional references to dynamic components.", + "$vocabulary": { + "https://json-schema.org/draft/2020-12/vocab/core": true, + "https://json-schema.org/draft/2020-12/vocab/applicator": true, + "https://json-schema.org/draft/2020-12/vocab/validation": true, + "https://json-schema.org/draft/2020-12/vocab/meta-data": false, + "https://json-schema.org/draft/2020-12/vocab/format-annotation": false + }, + "title": "Pet", + "description": "Schema for a pet object", + "type": "object", + "properties": { + "name": { + "type": "string", + "$comment": "The pet's full name" + }, + "address": { + "$dynamicRef": "#addressDef", + "$comment": "Reference to an address definition which can change dynamically" + } + }, + "required": [ + "name" + ], + "$dynamicAnchor": "addressDef" + } + } + } + } + } + } + } + }, + "components": { + "securitySchemes": { + "api_key": { + "type": "apiKey", + "name": "api_key", + "in": "header" + } + }, + "schemas": { + "Pet": { + "$id": "https://example.com/schemas/pet.json", + "type": "object", + "required": [ + "id", + "weight" + ], + "properties": { + "id": { + "type": "string", + "format": "uuid" + }, + "weight": { + "type": "number", + "exclusiveMinimum": 0, + "description": "Weight of the pet in kilograms" + }, + "attributes": { + "type": [ + "object", + "null" + ], + "description": "Dynamic attributes for the pet", + "patternProperties": { + "^attr_[A-Za-z]+$": { + "type": "string" + } + } + } + }, + "$comment": "This schema represents a pet in the system.", + "$defs": { + "ExtraInfo": { + "type": "string" + } + } + } + } + } +} \ No newline at end of file From bf9954a257691231fac6f56667bde208a98a5b42 Mon Sep 17 00:00:00 2001 From: Martin Costello Date: Tue, 15 Apr 2025 13:25:00 +0100 Subject: [PATCH 084/984] fix: Improve handling of OpenAPI tag references (#2325) * Fix OpenApiTagComparer behaviour Update `OpenApiTagComparer` to behave intuitively with `OpenApiTagReference` instances pointing to tags not defined in an `OpenApiDocument`. Contributes to #2319. * Verify tag references on serialization Verify OpenAPI tag references refer to a valid OpenAPI tag in the document on serialization. Resolves #2319. --- .../Models/OpenApiOperation.cs | 23 +++- .../Models/References/OpenApiTagReference.cs | 1 - src/Microsoft.OpenApi/OpenApiTagComparer.cs | 15 ++- .../Services/OpenApiFilterServiceTests.cs | 7 +- .../docWithReusableHeadersAndExamples.yaml | 2 + ...DocumentWith31PropertiesWorks.verified.txt | 2 + .../documentWith31Properties.yaml | 3 + .../Models/OpenApiOperationTests.cs | 30 +++++ .../OpenApiTagComparerTests.cs | 114 ++++++++++++++++++ 9 files changed, 189 insertions(+), 8 deletions(-) diff --git a/src/Microsoft.OpenApi/Models/OpenApiOperation.cs b/src/Microsoft.OpenApi/Models/OpenApiOperation.cs index 592d9cb58..3024f230a 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiOperation.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiOperation.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; +using Microsoft.OpenApi.Exceptions; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models.Interfaces; using Microsoft.OpenApi.Models.References; @@ -86,7 +87,7 @@ public HashSet? Tags /// /// REQUIRED. The list of possible responses as they are returned from executing this operation. /// - public OpenApiResponses? Responses { get; set; } = new(); + public OpenApiResponses? Responses { get; set; } = []; /// /// A map of possible out-of band callbacks related to the parent operation. @@ -182,7 +183,7 @@ private void SerializeInternal(IOpenApiWriter writer, OpenApiSpecVersion version // tags writer.WriteOptionalCollection( OpenApiConstants.Tags, - Tags, + VerifyTagReferences(Tags), callback); // summary @@ -236,7 +237,7 @@ public void SerializeAsV2(IOpenApiWriter writer) // tags writer.WriteOptionalCollection( OpenApiConstants.Tags, - Tags, + VerifyTagReferences(Tags), (w, t) => t.SerializeAsV2(w)); // summary @@ -355,5 +356,21 @@ public void SerializeAsV2(IOpenApiWriter writer) writer.WriteEndObject(); } + + private static HashSet? VerifyTagReferences(HashSet? tags) + { + if (tags?.Count > 0) + { + foreach (var tag in tags) + { + if (tag.Target is null) + { + throw new OpenApiException($"The OpenAPI tag reference '{tag.Reference.Id}' does reference a valid tag."); + } + } + } + + return tags; + } } } diff --git a/src/Microsoft.OpenApi/Models/References/OpenApiTagReference.cs b/src/Microsoft.OpenApi/Models/References/OpenApiTagReference.cs index cd3af84ba..769764c9d 100644 --- a/src/Microsoft.OpenApi/Models/References/OpenApiTagReference.cs +++ b/src/Microsoft.OpenApi/Models/References/OpenApiTagReference.cs @@ -1,7 +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.Interfaces; diff --git a/src/Microsoft.OpenApi/OpenApiTagComparer.cs b/src/Microsoft.OpenApi/OpenApiTagComparer.cs index dfa89e87f..ac467da43 100644 --- a/src/Microsoft.OpenApi/OpenApiTagComparer.cs +++ b/src/Microsoft.OpenApi/OpenApiTagComparer.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using Microsoft.OpenApi.Models.Interfaces; +using Microsoft.OpenApi.Models.References; namespace Microsoft.OpenApi; @@ -31,6 +32,10 @@ public bool Equals(IOpenApiTag? x, IOpenApiTag? y) { return true; } + if (x is OpenApiTagReference referenceX && y is OpenApiTagReference referenceY) + { + return StringComparer.Equals(referenceX.Name ?? referenceX.Reference.Id, referenceY.Name ?? referenceY.Reference.Id); + } return StringComparer.Equals(x.Name, y.Name); } @@ -41,5 +46,13 @@ public bool Equals(IOpenApiTag? x, IOpenApiTag? y) internal static readonly StringComparer StringComparer = StringComparer.Ordinal; /// - public int GetHashCode(IOpenApiTag obj) => string.IsNullOrEmpty(obj?.Name) ? 0 : StringComparer.GetHashCode(obj!.Name); + public int GetHashCode(IOpenApiTag obj) + { + string? value = obj?.Name; + if (value is null && obj is OpenApiTagReference reference) + { + value = reference.Reference.Id; + } + return string.IsNullOrEmpty(value) ? 0 : StringComparer.GetHashCode(value); + } } diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs index e617d3b3c..4b17ad699 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs +++ b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs @@ -244,7 +244,7 @@ public async Task CopiesOverAllReferencedComponentsToTheSubsetDocumentCorrectly( var openApiOperationTags = doc?.Paths["/items"].Operations?[HttpMethod.Get].Tags?.ToArray(); Assert.NotNull(openApiOperationTags); Assert.Single(openApiOperationTags); - Assert.True(openApiOperationTags[0].UnresolvedReference); + Assert.NotNull(openApiOperationTags[0].Target); var predicate = OpenApiFilterService.CreatePredicate(operationIds: operationIds); if (doc is not null) @@ -271,7 +271,7 @@ public async Task CopiesOverAllReferencedComponentsToTheSubsetDocumentCorrectly( var trimmedOpenApiOperationTags = subsetOpenApiDocument.Paths?["/items"].Operations?[HttpMethod.Get].Tags?.ToArray(); Assert.NotNull(trimmedOpenApiOperationTags); Assert.Single(trimmedOpenApiOperationTags); - Assert.True(trimmedOpenApiOperationTags[0].UnresolvedReference); + Assert.NotNull(trimmedOpenApiOperationTags[0].Target); // Finally try to write the trimmed document as v3 document var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); @@ -302,7 +302,8 @@ public void ReturnsPathParametersOnSlicingBasedOnOperationIdsOrTags(string? oper // Assert foreach (var pathItem in subsetOpenApiDocument.Paths) { - Assert.True(pathItem.Value.Parameters!.Count != 0); + Assert.NotNull(pathItem.Value.Parameters); + Assert.NotEmpty(pathItem.Value.Parameters); Assert.Single(pathItem.Value.Parameters!); } } diff --git a/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/docWithReusableHeadersAndExamples.yaml b/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/docWithReusableHeadersAndExamples.yaml index 8edeb1945..60ccbe057 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/docWithReusableHeadersAndExamples.yaml +++ b/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/docWithReusableHeadersAndExamples.yaml @@ -81,3 +81,5 @@ components: value: name: "New Item" +tags: + - name: list.items diff --git a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentTests.ParseDocumentWith31PropertiesWorks.verified.txt b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentTests.ParseDocumentWith31PropertiesWorks.verified.txt index fa7dd54e4..71e0e5887 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentTests.ParseDocumentWith31PropertiesWorks.verified.txt +++ b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentTests.ParseDocumentWith31PropertiesWorks.verified.txt @@ -99,6 +99,8 @@ components: in: header security: - api_key: [ ] +tags: + - name: pets webhooks: newPetAlert: post: diff --git a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/Samples/OpenApiDocument/documentWith31Properties.yaml b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/Samples/OpenApiDocument/documentWith31Properties.yaml index e3d1b6cf5..b64b5aa7e 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/Samples/OpenApiDocument/documentWith31Properties.yaml +++ b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/Samples/OpenApiDocument/documentWith31Properties.yaml @@ -122,5 +122,8 @@ components: ExtraInfo: type: string +tags: + - name: pets + security: - api_key: [] \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs index a862abdd6..3c465f576 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Text.Json.Nodes; using System.Threading.Tasks; +using Microsoft.OpenApi.Exceptions; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.Interfaces; @@ -859,5 +860,34 @@ public void OpenApiOperationCopyConstructorWithAnnotationsSucceeds() Assert.NotEqual(baseOperation.Metadata["key1"], actualOperation.Metadata["key1"]); } + + [Theory] + [InlineData(OpenApiSpecVersion.OpenApi2_0)] + [InlineData(OpenApiSpecVersion.OpenApi3_0)] + [InlineData(OpenApiSpecVersion.OpenApi3_1)] + public async Task SerializeAsJsonAsyncThrowsIfTagReferenceIsUnresolved(OpenApiSpecVersion version) + { + var document = new OpenApiDocument() + { + Tags = + [ + new() { Name = "one" }, + new() { Name = "three" } + ] + }; + + var operation = new OpenApiOperation() + { + Tags = + [ + new OpenApiTagReference("one", document), + new OpenApiTagReference("two", document), + new OpenApiTagReference("three", document) + ] + }; + + var exception = await Assert.ThrowsAsync(() => operation.SerializeAsJsonAsync(version)); + Assert.Equal("The OpenAPI tag reference 'two' does reference a valid tag.", exception.Message); + } } } diff --git a/test/Microsoft.OpenApi.Tests/OpenApiTagComparerTests.cs b/test/Microsoft.OpenApi.Tests/OpenApiTagComparerTests.cs index 9ea0c498c..c3cbc2d1a 100644 --- a/test/Microsoft.OpenApi.Tests/OpenApiTagComparerTests.cs +++ b/test/Microsoft.OpenApi.Tests/OpenApiTagComparerTests.cs @@ -1,4 +1,7 @@ +using System.Collections.Generic; +using System.Linq; using Microsoft.OpenApi.Models; +using Microsoft.OpenApi.Models.References; using Xunit; namespace Microsoft.OpenApi.Tests; @@ -6,6 +9,7 @@ namespace Microsoft.OpenApi.Tests; public class OpenApiTagComparerTests { private readonly OpenApiTagComparer _comparer = OpenApiTagComparer.Instance; + [Fact] public void Defensive() { @@ -16,6 +20,7 @@ public void Defensive() Assert.Equal(0, _comparer.GetHashCode(null)); Assert.Equal(0, _comparer.GetHashCode(new OpenApiTag())); } + [Fact] public void SameNamesAreEqual() { @@ -23,6 +28,7 @@ public void SameNamesAreEqual() var openApiTag2 = new OpenApiTag { Name = "tag" }; Assert.True(_comparer.Equals(openApiTag1, openApiTag2)); } + [Fact] public void SameInstanceAreEqual() { @@ -37,4 +43,112 @@ public void DifferentCasingAreNotEquals() var openApiTag2 = new OpenApiTag { Name = "TAG" }; Assert.False(_comparer.Equals(openApiTag1, openApiTag2)); } + + [Fact] + public void WorksCorrectlyWithHashSetOfTags() + { + var tags = new HashSet(_comparer) + { + new() { Name = "one" }, + new() { Name = "two" }, + new() { Name = "two" }, + new() { Name = "three" } + }; + + Assert.Equal(["one", "two", "three"], [.. tags.Select(t => t.Name)]); + } + + [Fact] + public void SameReferenceInstanceAreEqual() + { + var openApiTag = new OpenApiTagReference("tag"); + Assert.True(_comparer.Equals(openApiTag, openApiTag)); + } + + [Fact] + public void SameReferenceIdsAreEqual() + { + var openApiTag1 = new OpenApiTagReference("tag"); + var openApiTag2 = new OpenApiTagReference("tag"); + Assert.True(_comparer.Equals(openApiTag1, openApiTag2)); + } + + [Fact] + public void SameReferenceIdAreEqualWithValidTagReferences() + { + var document = new OpenApiDocument + { + Tags = [new() { Name = "tag" }] + }; + + var openApiTag1 = new OpenApiTagReference("tag", document); + var openApiTag2 = new OpenApiTagReference("tag", document); + Assert.True(_comparer.Equals(openApiTag1, openApiTag2)); + } + + [Fact] + public void DifferentReferenceIdAreNotEqualWithValidTagReferences() + { + var document = new OpenApiDocument + { + Tags = + [ + new() { Name = "one" }, + new() { Name = "two" }, + ] + }; + + var openApiTag1 = new OpenApiTagReference("one", document); + var openApiTag2 = new OpenApiTagReference("two", document); + Assert.False(_comparer.Equals(openApiTag1, openApiTag2)); + } + + [Fact] + public void DifferentCasingReferenceIdsAreNotEqual() + { + var openApiTag1 = new OpenApiTagReference("tag"); + var openApiTag2 = new OpenApiTagReference("TAG"); + Assert.False(_comparer.Equals(openApiTag1, openApiTag2)); + } + + [Fact] // See https://github.com/microsoft/OpenAPI.NET/issues/2319 + public void WorksCorrectlyWithHashSetOfReferences() + { + // The document intentionally does not contain the actual tags + var document = new OpenApiDocument(); + + var tags = new HashSet(_comparer) + { + new("one", document), + new("two", document), + new("two", document), + new("three", document) + }; + + Assert.Equal(["one", "two", "three"], [..tags.Select(t => t.Reference.Id)]); + } + + [Fact] + public void WorksCorrectlyWithHashSetOfReferencesToValidTags() + { + var document = new OpenApiDocument + { + Tags = + [ + new() { Name = "one" }, + new() { Name = "two" }, + new() { Name = "three" } + ] + }; + + var tags = new HashSet(_comparer) + { + new("one", document), + new("two", document), + new("two", document), + new("three", document) + }; + + Assert.Equal(["one", "two", "three"], [.. tags.Select(t => t.Reference.Id)]); + } } From 269a215b523e8ef617a6e5e45dce098a1a2ef998 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Tue, 15 Apr 2025 09:39:20 -0400 Subject: [PATCH 085/984] fix: use of reflection during YAML serialization Signed-off-by: Vincent Biret --- .../Writers/OpenApiWriterBase.cs | 44 +++++++++---------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/src/Microsoft.OpenApi/Writers/OpenApiWriterBase.cs b/src/Microsoft.OpenApi/Writers/OpenApiWriterBase.cs index 0f212477a..f867f7986 100644 --- a/src/Microsoft.OpenApi/Writers/OpenApiWriterBase.cs +++ b/src/Microsoft.OpenApi/Writers/OpenApiWriterBase.cs @@ -238,47 +238,45 @@ public virtual void WriteValue(object? value) return; } - var type = value.GetType(); - - if (type == typeof(string)) + if (value is string strValue) { - WriteValue((string)(value)); + WriteValue(strValue); } - else if (type == typeof(int) || type == typeof(int?)) + else if (value is int intValue) { - WriteValue((int)value); + WriteValue(intValue); } - else if (type == typeof(uint) || type == typeof(uint?)) + else if (value is uint uintValue) { - WriteValue((uint)value); + WriteValue(uintValue); } - else if (type == typeof(long) || type == typeof(long?)) + else if (value is long longValue) { - WriteValue((long)value); + WriteValue(longValue); } - else if (type == typeof(bool) || type == typeof(bool?)) + else if (value is bool boolValue) { - WriteValue((bool)value); + WriteValue(boolValue); } - else if (type == typeof(float) || type == typeof(float?)) + else if (value is float floatValue) { - WriteValue((float)value); + WriteValue(floatValue); } - else if (type == typeof(double) || type == typeof(double?)) + else if (value is double doubleValue) { - WriteValue((double)value); + WriteValue(doubleValue); } - else if (type == typeof(decimal) || type == typeof(decimal?)) + else if (value is decimal decimalValue) { - WriteValue((decimal)value); + WriteValue(decimalValue); } - else if (type == typeof(DateTime) || type == typeof(DateTime?)) + else if (value is DateTime DateTimeValue) { - WriteValue((DateTime)value); + WriteValue(DateTimeValue); } - else if (type == typeof(DateTimeOffset) || type == typeof(DateTimeOffset?)) + else if (value is DateTimeOffset DateTimeOffsetValue) { - WriteValue((DateTimeOffset)value); + WriteValue(DateTimeOffsetValue); } else if (value is IEnumerable enumerable) { @@ -286,7 +284,7 @@ public virtual void WriteValue(object? value) } else { - throw new OpenApiWriterException(string.Format(SRResource.OpenApiUnsupportedValueType, type.FullName)); + throw new OpenApiWriterException(string.Format(SRResource.OpenApiUnsupportedValueType, value.GetType().FullName)); } } From 528fb1b9600d15604df9c829ce074f143bde36bb Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Tue, 15 Apr 2025 09:40:49 -0400 Subject: [PATCH 086/984] chore: removes redundant null propagation operator Signed-off-by: Vincent Biret --- src/Microsoft.OpenApi/Writers/OpenApiWriterAnyExtensions.cs | 2 +- src/Microsoft.OpenApi/Writers/OpenApiYamlWriter.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.OpenApi/Writers/OpenApiWriterAnyExtensions.cs b/src/Microsoft.OpenApi/Writers/OpenApiWriterAnyExtensions.cs index 222d7a24e..09ee79309 100644 --- a/src/Microsoft.OpenApi/Writers/OpenApiWriterAnyExtensions.cs +++ b/src/Microsoft.OpenApi/Writers/OpenApiWriterAnyExtensions.cs @@ -114,7 +114,7 @@ private static void WriteObject(this IOpenApiWriter writer, JsonObject? entity) private static void WritePrimitive(this IOpenApiWriter writer, JsonValue jsonValue) { - if (jsonValue.TryGetValue(out string? stringValue)) + if (jsonValue.TryGetValue(out string? stringValue) && stringValue is not null) writer.WriteValue(stringValue); else if (jsonValue.TryGetValue(out DateTime dateTimeValue)) writer.WriteValue(dateTimeValue.ToString("o", CultureInfo.InvariantCulture)); // ISO 8601 format diff --git a/src/Microsoft.OpenApi/Writers/OpenApiYamlWriter.cs b/src/Microsoft.OpenApi/Writers/OpenApiYamlWriter.cs index 49e8f0cb4..ce11a3784 100644 --- a/src/Microsoft.OpenApi/Writers/OpenApiYamlWriter.cs +++ b/src/Microsoft.OpenApi/Writers/OpenApiYamlWriter.cs @@ -170,7 +170,7 @@ public override void WritePropertyName(string name) /// The string value. public override void WriteValue(string value) { - if (!UseLiteralStyle || value?.IndexOfAny(new[] { '\n', '\r' }) == -1) + if (!UseLiteralStyle || value.IndexOfAny(['\n', '\r']) == -1) { WriteValueSeparator(); @@ -190,7 +190,7 @@ public override void WriteValue(string value) WriteChompingIndicator(value); // Write indentation indicator when it starts with spaces - if (value is not null && value.StartsWith(" ", StringComparison.OrdinalIgnoreCase)) + if (value[0] == ' ') { Writer.Write(IndentationString.Length); } From fed88ebb3bd2fb41b250cc83940af251c58ad6d9 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Tue, 15 Apr 2025 09:46:16 -0400 Subject: [PATCH 087/984] fix: redundant loop in v2 schema serialization Signed-off-by: Vincent Biret --- src/Microsoft.OpenApi/Models/OpenApiDocument.cs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs index 3b616f821..c5ac5f759 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs @@ -296,15 +296,12 @@ public void SerializeAsV2(IOpenApiWriter writer) .OfType() .Where(k => k.Reference?.Id is not null) .ToDictionary( - k => k.Reference?.Id!, + k => k.Reference.Id!, v => v ); - foreach (var schema in openApiSchemas.Values.ToList()) - { - FindSchemaReferences.ResolveSchemas(Components, openApiSchemas!); - } + FindSchemaReferences.ResolveSchemas(Components, openApiSchemas); writer.WriteOptionalMap( OpenApiConstants.Definitions, @@ -723,8 +720,10 @@ internal class FindSchemaReferences : OpenApiVisitorBase public static void ResolveSchemas(OpenApiComponents? components, Dictionary schemas) { - var visitor = new FindSchemaReferences(); - visitor.Schemas = schemas; + var visitor = new FindSchemaReferences + { + Schemas = schemas + }; var walker = new OpenApiWalker(visitor); walker.Walk(components); } From 4965a7be64af114f97141b56c5371d38a64f1901 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Tue, 15 Apr 2025 09:50:53 -0400 Subject: [PATCH 088/984] chore: cleans up unnecessary type tests Signed-off-by: Vincent Biret --- .../OpenApiReferencableExtensions.cs | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/Microsoft.OpenApi/Extensions/OpenApiReferencableExtensions.cs b/src/Microsoft.OpenApi/Extensions/OpenApiReferencableExtensions.cs index df266b577..a282bcba4 100644 --- a/src/Microsoft.OpenApi/Extensions/OpenApiReferencableExtensions.cs +++ b/src/Microsoft.OpenApi/Extensions/OpenApiReferencableExtensions.cs @@ -64,10 +64,9 @@ private static IOpenApiReferenceable ResolveReferenceOnHeaderElement( if (OpenApiConstants.Examples.Equals(propertyName, StringComparison.Ordinal) && !string.IsNullOrEmpty(mapKey) && headerElement?.Examples != null && - headerElement.Examples.TryGetValue(mapKey, out var exampleElement) && - exampleElement is IOpenApiReferenceable referenceable) + headerElement.Examples.TryGetValue(mapKey, out var exampleElement)) { - return referenceable; + return exampleElement; } throw new OpenApiException(string.Format(SRResource.InvalidReferenceId, pointer)); } @@ -81,10 +80,9 @@ private static IOpenApiReferenceable ResolveReferenceOnParameterElement( if (OpenApiConstants.Examples.Equals(propertyName, StringComparison.Ordinal) && !string.IsNullOrEmpty(mapKey) && parameterElement?.Examples != null && - parameterElement.Examples.TryGetValue(mapKey, out var exampleElement) && - exampleElement is IOpenApiReferenceable referenceable) + parameterElement.Examples.TryGetValue(mapKey, out var exampleElement)) { - return referenceable; + return exampleElement; } throw new OpenApiException(string.Format(SRResource.InvalidReferenceId, pointer)); } @@ -99,17 +97,15 @@ private static IOpenApiReferenceable ResolveReferenceOnResponseElement( { if (OpenApiConstants.Headers.Equals(propertyName, StringComparison.Ordinal) && responseElement?.Headers != null && - responseElement.Headers.TryGetValue(mapKey, out var headerElement) && - headerElement is IOpenApiReferenceable referenceable) + responseElement.Headers.TryGetValue(mapKey, out var headerElement)) { - return referenceable; + return headerElement; } if (OpenApiConstants.Links.Equals(propertyName, StringComparison.Ordinal) && responseElement?.Links != null && - responseElement.Links.TryGetValue(mapKey, out var linkElement) && - linkElement is IOpenApiReferenceable referenceable2) + responseElement.Links.TryGetValue(mapKey, out var linkElement)) { - return referenceable2; + return linkElement; } } throw new OpenApiException(string.Format(SRResource.InvalidReferenceId, pointer)); From 07209a6496181c430e0db7fef7e6ec38c327a2c8 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Tue, 15 Apr 2025 10:07:41 -0400 Subject: [PATCH 089/984] chore: fixes equals implementation Signed-off-by: Vincent Biret --- .../Expressions/RuntimeExpression.cs | 20 ++++++++++++------- .../PublicApi/PublicApi.approved.txt | 2 +- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/Microsoft.OpenApi/Expressions/RuntimeExpression.cs b/src/Microsoft.OpenApi/Expressions/RuntimeExpression.cs index b6104e1b3..31e2d29ae 100644 --- a/src/Microsoft.OpenApi/Expressions/RuntimeExpression.cs +++ b/src/Microsoft.OpenApi/Expressions/RuntimeExpression.cs @@ -78,7 +78,7 @@ public static RuntimeExpression Build(string expression) /// public override int GetHashCode() { - return Expression.GetHashCode(); + return StringComparer.Ordinal.GetHashCode(Expression); } /// @@ -86,15 +86,21 @@ public override int GetHashCode() /// public override bool Equals(object? obj) { - return Equals(obj as RuntimeExpression); + if (obj == null) + { + return false; + } + if (ReferenceEquals(this, obj)) + { + return true; + } + return obj is RuntimeExpression runtimeExpression && Equals(runtimeExpression); } - /// - /// Equals implementation for object of the same type. - /// - public bool Equals(RuntimeExpression? obj) + /// + public bool Equals(RuntimeExpression? other) { - return obj != null && obj.Expression == Expression; + return other is not null && StringComparer.Ordinal.Equals(Expression, other.Expression); } /// diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index 2ec1fb15b..b3a8e2c37 100644 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -115,7 +115,7 @@ namespace Microsoft.OpenApi.Expressions public const string Prefix = "$"; protected RuntimeExpression() { } public abstract string Expression { get; } - public bool Equals(Microsoft.OpenApi.Expressions.RuntimeExpression? obj) { } + public bool Equals(Microsoft.OpenApi.Expressions.RuntimeExpression? other) { } public override bool Equals(object? obj) { } public override int GetHashCode() { } public override string ToString() { } From 7b1a2404be89e94273466cfacc51d15267325d10 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Tue, 15 Apr 2025 16:21:26 -0400 Subject: [PATCH 090/984] Potential fix for code scanning alert no. 2302: Equals should not apply "is" Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- src/Microsoft.OpenApi/Expressions/RuntimeExpression.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi/Expressions/RuntimeExpression.cs b/src/Microsoft.OpenApi/Expressions/RuntimeExpression.cs index 31e2d29ae..ca5f9ccaf 100644 --- a/src/Microsoft.OpenApi/Expressions/RuntimeExpression.cs +++ b/src/Microsoft.OpenApi/Expressions/RuntimeExpression.cs @@ -94,7 +94,7 @@ public override bool Equals(object? obj) { return true; } - return obj is RuntimeExpression runtimeExpression && Equals(runtimeExpression); + return obj.GetType() == GetType() && Equals((RuntimeExpression)obj); } /// From 19ffd136a7d2137f3de0896148d9a39f469ac711 Mon Sep 17 00:00:00 2001 From: Michael Wamae <68949852+Michael-Wamae@users.noreply.github.com> Date: Wed, 16 Apr 2025 13:49:02 +0300 Subject: [PATCH 091/984] feat: openapiformat enum cleanup (#2326) * feat: openapiformat enum cleanup * align string options Co-authored-by: Vincent Biret * resolve PR comments --------- Co-authored-by: Vincent Biret --- README.md | 2 +- docs/upgrade-guide-2.md | 16 +++++++++- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 31 ++++++++++--------- .../Options/CommandOptions.cs | 2 +- .../Options/HidiOptions.cs | 2 +- src/Microsoft.OpenApi.Workbench/MainModel.cs | 16 +++++----- .../OpenApiSerializableExtensions.cs | 21 +++++++------ src/Microsoft.OpenApi/OpenApiFormat.cs | 21 ------------- .../Services/OpenApiServiceTests.cs | 4 +-- .../Models/OpenApiContactTests.cs | 10 +++--- .../Models/OpenApiDocumentTests.cs | 2 +- .../Models/OpenApiEncodingTests.cs | 6 ++-- .../Models/OpenApiExternalDocsTests.cs | 6 ++-- .../Models/OpenApiInfoTests.cs | 2 +- .../Models/OpenApiMediaTypeTests.cs | 6 ++-- .../Models/OpenApiResponseTests.cs | 12 +++---- .../Models/OpenApiServerVariableTests.cs | 6 ++-- .../Models/OpenApiXmlTests.cs | 10 +++--- .../PublicApi/PublicApi.approved.txt | 11 ++----- 19 files changed, 88 insertions(+), 98 deletions(-) delete mode 100644 src/Microsoft.OpenApi/OpenApiFormat.cs diff --git a/README.md b/README.md index f903038cd..ef93e1450 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,7 @@ var stream = await httpClient.GetStreamAsync("main/examples/v3.0/petstore.yaml") var openApiDocument = new OpenApiStreamReader().Read(stream, out var diagnostic); // Write V2 as JSON -var outputString = openApiDocument.Serialize(OpenApiSpecVersion.OpenApi2_0, OpenApiFormat.Json); +var outputString = openApiDocument.Serialize(OpenApiSpecVersion.OpenApi2_0, OpenApiConstants.Json); ``` diff --git a/docs/upgrade-guide-2.md b/docs/upgrade-guide-2.md index c1416b8fe..f1fd6c23f 100644 --- a/docs/upgrade-guide-2.md +++ b/docs/upgrade-guide-2.md @@ -487,10 +487,24 @@ The `SerializeAs()` method simplifies serialization scenarios, making it easier ```csharp OpenApiDocument document = new OpenApiDocument(); -string json = document.SerializeAs(OpenApiSpecVersion.OpenApi3_0, OpenApiFormat.Json); +string json = document.SerializeAs(OpenApiSpecVersion.OpenApi3_0, OpenApiConstants.Json); ``` +### Use OpenApiConstants string Instead of OpenApiFormat Enum + +OpenApiConstants are now used instead of OpenApiFormat enums. + +**Example:** + +```csharp +// Before (1.6) +var outputString = openApiDocument.Serialize(OpenApiSpecVersion.OpenApi2_0, OpenApiFormat.Json); + +// After (2.0) +var outputString = openApiDocument.Serialize(OpenApiSpecVersion.OpenApi2_0, OpenApiConstants.Json); +``` + ### Bug Fixes ## Serialization of References diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index 8b412d14f..52d25ef27 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -55,7 +55,7 @@ public static async Task TransformOpenApiDocumentAsync(HidiOptions options, ILog if (options.Output == null) { #pragma warning disable CA1308 // Normalize strings to uppercase - var extension = options.OpenApiFormat?.GetDisplayName().ToLowerInvariant(); + var extension = options.OpenApiFormat?.ToLowerInvariant(); var inputExtension = !string.IsNullOrEmpty(extension) ? string.Concat(".", extension) : GetInputPathExtension(options.OpenApi, options.Csdl); @@ -73,7 +73,7 @@ public static async Task TransformOpenApiDocumentAsync(HidiOptions options, ILog } // Default to yaml and OpenApiVersion 3_1 during csdl to OpenApi conversion - var openApiFormat = options.OpenApiFormat ?? (!string.IsNullOrEmpty(options.OpenApi) ? GetOpenApiFormat(options.OpenApi, logger) : OpenApiFormat.Yaml); + var openApiFormat = options.OpenApiFormat ?? (!string.IsNullOrEmpty(options.OpenApi) ? GetOpenApiFormat(options.OpenApi, logger) : OpenApiConstants.Yaml); var openApiVersion = options.Version != null ? TryParseOpenApiSpecVersion(options.Version) : OpenApiSpecVersion.OpenApi3_1; // If ApiManifest is provided, set the referenced OpenAPI document @@ -92,7 +92,7 @@ public static async Task TransformOpenApiDocumentAsync(HidiOptions options, ILog } // Load OpenAPI document - var document = await GetOpenApiAsync(options, openApiFormat.GetDisplayName(), logger, options.MetadataVersion, cancellationToken).ConfigureAwait(false); + var document = await GetOpenApiAsync(options, openApiFormat, logger, options.MetadataVersion, cancellationToken).ConfigureAwait(false); if (options.FilterOptions != null && document is not null) { @@ -189,7 +189,7 @@ private static OpenApiDocument ApplyFilters(HidiOptions options, ILogger logger, return document; } - private static async Task WriteOpenApiAsync(HidiOptions options, OpenApiFormat openApiFormat, OpenApiSpecVersion openApiVersion, OpenApiDocument document, ILogger logger, CancellationToken cancellationToken) + private static async Task WriteOpenApiAsync(HidiOptions options, string openApiFormat, OpenApiSpecVersion openApiVersion, OpenApiDocument document, ILogger logger, CancellationToken cancellationToken) { using (logger.BeginScope("Output")) { @@ -202,11 +202,12 @@ private static async Task WriteOpenApiAsync(HidiOptions options, OpenApiFormat o InlineLocalReferences = options.InlineLocal, InlineExternalReferences = options.InlineExternal }; - - IOpenApiWriter writer = openApiFormat switch +#pragma warning disable CA1308 + IOpenApiWriter writer = openApiFormat.ToLowerInvariant() switch +#pragma warning restore CA1308 { - OpenApiFormat.Json => options.TerseOutput ? new(textWriter, settings, options.TerseOutput) : new OpenApiJsonWriter(textWriter, settings, false), - OpenApiFormat.Yaml => new OpenApiYamlWriter(textWriter, settings), + OpenApiConstants.Json => options.TerseOutput ? new(textWriter, settings, options.TerseOutput) : new OpenApiJsonWriter(textWriter, settings, false), + OpenApiConstants.Yaml => new OpenApiYamlWriter(textWriter, settings), _ => throw new ArgumentException("Unknown format"), }; @@ -560,10 +561,10 @@ SecurityException or /// /// /// - private static OpenApiFormat GetOpenApiFormat(string input, ILogger logger) + private static string GetOpenApiFormat(string input, ILogger logger) { logger.LogTrace("Getting the OpenApi format"); - return !input.StartsWith("http", StringComparison.OrdinalIgnoreCase) && Path.GetExtension(input) == ".json" ? OpenApiFormat.Json : OpenApiFormat.Yaml; + return !input.StartsWith("http", StringComparison.OrdinalIgnoreCase) && Path.GetExtension(input) == ".json" ? OpenApiConstants.Json : OpenApiConstants.Yaml; } private static string GetInputPathExtension(string? openapi = null, string? csdl = null) @@ -590,8 +591,8 @@ private static string GetInputPathExtension(string? openapi = null, string? csdl throw new ArgumentException("Please input a file path or URL"); } - var openApiFormat = options.OpenApiFormat ?? (!string.IsNullOrEmpty(options.OpenApi) ? GetOpenApiFormat(options.OpenApi, logger) : OpenApiFormat.Yaml); - var document = await GetOpenApiAsync(options, openApiFormat.GetDisplayName(), logger, null, cancellationToken).ConfigureAwait(false); + var openApiFormat = options.OpenApiFormat ?? (!string.IsNullOrEmpty(options.OpenApi) ? GetOpenApiFormat(options.OpenApi, logger) : OpenApiConstants.Yaml); + var document = await GetOpenApiAsync(options, openApiFormat, logger, null, cancellationToken).ConfigureAwait(false); if (document is not null) { using (logger.BeginScope("Creating diagram")) @@ -754,10 +755,10 @@ internal static async Task PluginManifestAsync(HidiOptions options, ILogger logg } var openApiFormat = options.OpenApiFormat ?? (!string.IsNullOrEmpty(options.OpenApi) - ? GetOpenApiFormat(options.OpenApi, logger) : OpenApiFormat.Yaml); + ? GetOpenApiFormat(options.OpenApi, logger) : OpenApiConstants.Yaml); // Load OpenAPI document - var document = await GetOpenApiAsync(options, openApiFormat.GetDisplayName(), logger, options.MetadataVersion, cancellationToken).ConfigureAwait(false); + var document = await GetOpenApiAsync(options, openApiFormat, logger, options.MetadataVersion, cancellationToken).ConfigureAwait(false); cancellationToken.ThrowIfCancellationRequested(); @@ -777,7 +778,7 @@ internal static async Task PluginManifestAsync(HidiOptions options, ILogger logg options.TerseOutput = true; if (document is not null) { - await WriteOpenApiAsync(options, OpenApiFormat.Json, OpenApiSpecVersion.OpenApi3_1, document, logger, cancellationToken).ConfigureAwait(false); + await WriteOpenApiAsync(options, OpenApiConstants.Json, OpenApiSpecVersion.OpenApi3_1, document, logger, cancellationToken).ConfigureAwait(false); // Create OpenAIPluginManifest from ApiDependency and OpenAPI document var manifest = new OpenAIPluginManifest(document.Info.Title ?? "Title", diff --git a/src/Microsoft.OpenApi.Hidi/Options/CommandOptions.cs b/src/Microsoft.OpenApi.Hidi/Options/CommandOptions.cs index 6fee866cb..908435c33 100644 --- a/src/Microsoft.OpenApi.Hidi/Options/CommandOptions.cs +++ b/src/Microsoft.OpenApi.Hidi/Options/CommandOptions.cs @@ -16,7 +16,7 @@ internal class CommandOptions public readonly Option CleanOutputOption = new("--clean-output", "Overwrite an existing file"); public readonly Option VersionOption = new("--version", "OpenAPI specification version"); public readonly Option MetadataVersionOption = new("--metadata-version", "Graph metadata version to use."); - public readonly Option FormatOption = new("--format", "File format"); + public readonly Option FormatOption = new("--format", "File format"); public readonly Option TerseOutputOption = new("--terse-output", "Produce terse json output"); public readonly Option SettingsFileOption = new("--settings-path", "The configuration file with CSDL conversion settings."); public readonly Option LogLevelOption = new("--log-level", () => LogLevel.Information, "The log level to use when logging messages to the main output."); diff --git a/src/Microsoft.OpenApi.Hidi/Options/HidiOptions.cs b/src/Microsoft.OpenApi.Hidi/Options/HidiOptions.cs index fca97c87f..127a0a14a 100644 --- a/src/Microsoft.OpenApi.Hidi/Options/HidiOptions.cs +++ b/src/Microsoft.OpenApi.Hidi/Options/HidiOptions.cs @@ -20,7 +20,7 @@ internal class HidiOptions public bool CleanOutput { get; set; } public string? Version { get; set; } public string? MetadataVersion { get; set; } - public OpenApiFormat? OpenApiFormat { get; set; } + public string? OpenApiFormat { get; set; } public bool TerseOutput { get; set; } public IConfiguration? SettingsConfig { get; set; } public LogLevel LogLevel { get; set; } diff --git a/src/Microsoft.OpenApi.Workbench/MainModel.cs b/src/Microsoft.OpenApi.Workbench/MainModel.cs index d4e469e8f..d065b36e7 100644 --- a/src/Microsoft.OpenApi.Workbench/MainModel.cs +++ b/src/Microsoft.OpenApi.Workbench/MainModel.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System; @@ -43,7 +43,7 @@ public class MainModel : INotifyPropertyChanged /// /// Default format. /// - private OpenApiFormat _format = OpenApiFormat.Yaml; + private string _format = OpenApiConstants.Yaml; /// /// Default version. @@ -121,7 +121,7 @@ public string RenderTime } } - public OpenApiFormat Format + public string Format { get => _format; set @@ -166,14 +166,14 @@ public OpenApiSpecVersion Version public bool IsYaml { - get => Format == OpenApiFormat.Yaml; - set => Format = value ? OpenApiFormat.Yaml : Format; + get => Format == OpenApiConstants.Yaml; + set => Format = value ? OpenApiConstants.Yaml : Format; } public bool IsJson { - get => Format == OpenApiFormat.Json; - set => Format = value ? OpenApiFormat.Json : Format; + get => Format == OpenApiConstants.Json; + set => Format = value ? OpenApiConstants.Json : Format; } public bool IsV2_0 @@ -243,7 +243,7 @@ internal async Task ParseDocumentAsync() : new("file://" + Path.GetDirectoryName(_inputFile) + "/"); } - var readResult = await OpenApiDocument.LoadAsync(stream, Format.GetDisplayName().ToLowerInvariant(), settings); + var readResult = await OpenApiDocument.LoadAsync(stream, Format.ToLowerInvariant(), settings); var document = readResult.Document; var context = readResult.Diagnostic; diff --git a/src/Microsoft.OpenApi/Extensions/OpenApiSerializableExtensions.cs b/src/Microsoft.OpenApi/Extensions/OpenApiSerializableExtensions.cs index d028cd5e4..dcee59faf 100755 --- a/src/Microsoft.OpenApi/Extensions/OpenApiSerializableExtensions.cs +++ b/src/Microsoft.OpenApi/Extensions/OpenApiSerializableExtensions.cs @@ -7,6 +7,7 @@ using System.Threading.Tasks; using Microsoft.OpenApi.Exceptions; using Microsoft.OpenApi.Interfaces; +using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Properties; using Microsoft.OpenApi.Writers; @@ -28,7 +29,7 @@ public static class OpenApiSerializableExtensions public static Task SerializeAsJsonAsync(this T element, Stream stream, OpenApiSpecVersion specVersion, CancellationToken cancellationToken = default) where T : IOpenApiSerializable { - return element.SerializeAsync(stream, specVersion, OpenApiFormat.Json, cancellationToken); + return element.SerializeAsync(stream, specVersion, OpenApiConstants.Json, cancellationToken); } /// @@ -42,7 +43,7 @@ public static Task SerializeAsJsonAsync(this T element, Stream stream, OpenAp public static Task SerializeAsYamlAsync(this T element, Stream stream, OpenApiSpecVersion specVersion, CancellationToken cancellationToken = default) where T : IOpenApiSerializable { - return element.SerializeAsync(stream, specVersion, OpenApiFormat.Yaml, cancellationToken); + return element.SerializeAsync(stream, specVersion, OpenApiConstants.Yaml, cancellationToken); } /// @@ -59,7 +60,7 @@ public static Task SerializeAsync( this T element, Stream stream, OpenApiSpecVersion specVersion, - OpenApiFormat format, + string format, CancellationToken cancellationToken = default) where T : IOpenApiSerializable { @@ -81,7 +82,7 @@ public static Task SerializeAsync( this T element, Stream stream, OpenApiSpecVersion specVersion, - OpenApiFormat format, + string format, OpenApiWriterSettings? settings = null, CancellationToken cancellationToken = default) where T : IOpenApiSerializable @@ -90,10 +91,10 @@ public static Task SerializeAsync( var streamWriter = new FormattingStreamWriter(stream, CultureInfo.InvariantCulture); - IOpenApiWriter writer = format switch + IOpenApiWriter writer = format.ToLowerInvariant() switch { - OpenApiFormat.Json => new OpenApiJsonWriter(streamWriter, settings, false), - OpenApiFormat.Yaml => new OpenApiYamlWriter(streamWriter, settings), + OpenApiConstants.Json => new OpenApiJsonWriter(streamWriter, settings, false), + OpenApiConstants.Yaml => new OpenApiYamlWriter(streamWriter, settings), _ => throw new OpenApiException(string.Format(SRResource.OpenApiFormatNotSupported, format)), }; return element.SerializeAsync(writer, specVersion, cancellationToken); @@ -147,7 +148,7 @@ public static Task SerializeAsJsonAsync( CancellationToken cancellationToken = default) where T : IOpenApiSerializable { - return element.SerializeAsync(specVersion, OpenApiFormat.Json, cancellationToken); + return element.SerializeAsync(specVersion, OpenApiConstants.Json, cancellationToken); } /// @@ -163,7 +164,7 @@ public static Task SerializeAsYamlAsync( CancellationToken cancellationToken = default) where T : IOpenApiSerializable { - return element.SerializeAsync(specVersion, OpenApiFormat.Yaml, cancellationToken); + return element.SerializeAsync(specVersion, OpenApiConstants.Yaml, cancellationToken); } /// @@ -177,7 +178,7 @@ public static Task SerializeAsYamlAsync( public static async Task SerializeAsync( this T element, OpenApiSpecVersion specVersion, - OpenApiFormat format, + string format, CancellationToken cancellationToken = default) where T : IOpenApiSerializable { diff --git a/src/Microsoft.OpenApi/OpenApiFormat.cs b/src/Microsoft.OpenApi/OpenApiFormat.cs deleted file mode 100644 index 8005d7d62..000000000 --- a/src/Microsoft.OpenApi/OpenApiFormat.cs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. - -namespace Microsoft.OpenApi -{ - /// - /// Represents the Open Api document format. - /// - public enum OpenApiFormat - { - /// - /// JSON format. - /// - Json, - - /// - /// Yaml format. - /// - Yaml - } -} diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs index 7e5b4de3c..97c27fe37 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs +++ b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs @@ -261,7 +261,7 @@ public async Task TransformCommandConvertsOpenApiWithDefaultOutputNameAndSwitchF OpenApi = Path.Combine("UtilityFiles", "SampleOpenApi.yml"), CleanOutput = true, Version = "3.0", - OpenApiFormat = OpenApiFormat.Yaml, + OpenApiFormat = OpenApiConstants.Yaml, TerseOutput = false, InlineLocal = false, InlineExternal = false, @@ -296,7 +296,7 @@ public async Task TransformToPowerShellCompliantOpenApiAsync() OpenApi = Path.Combine("UtilityFiles", "SampleOpenApi.yml"), CleanOutput = true, Version = "3.0", - OpenApiFormat = OpenApiFormat.Yaml, + OpenApiFormat = OpenApiConstants.Yaml, TerseOutput = false, InlineLocal = false, InlineExternal = false, diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiContactTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiContactTests.cs index 65f34c65b..114956a11 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiContactTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiContactTests.cs @@ -28,13 +28,13 @@ public class OpenApiContactTests }; [Theory] - [InlineData(OpenApiSpecVersion.OpenApi3_0, OpenApiFormat.Json, "{ }")] - [InlineData(OpenApiSpecVersion.OpenApi2_0, OpenApiFormat.Json, "{ }")] - [InlineData(OpenApiSpecVersion.OpenApi3_0, OpenApiFormat.Yaml, "{ }")] - [InlineData(OpenApiSpecVersion.OpenApi2_0, OpenApiFormat.Yaml, "{ }")] + [InlineData(OpenApiSpecVersion.OpenApi3_0, OpenApiConstants.Json, "{ }")] + [InlineData(OpenApiSpecVersion.OpenApi2_0, OpenApiConstants.Json, "{ }")] + [InlineData(OpenApiSpecVersion.OpenApi3_0, OpenApiConstants.Yaml, "{ }")] + [InlineData(OpenApiSpecVersion.OpenApi2_0, OpenApiConstants.Yaml, "{ }")] public async Task SerializeBasicContactWorks( OpenApiSpecVersion version, - OpenApiFormat format, + string format, string expected) { // Arrange & Act diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs index 2774680a7..48310df15 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs @@ -1557,7 +1557,7 @@ public async Task SerializeDocumentWithReferenceButNoComponents() document.Paths["/"].Operations[HttpMethod.Get].Responses["200"].Content["application/json"].Schema = new OpenApiSchemaReference("test", document); // Act - var actual = await document.SerializeAsync(OpenApiSpecVersion.OpenApi2_0, OpenApiFormat.Json); + var actual = await document.SerializeAsync(OpenApiSpecVersion.OpenApi2_0, OpenApiConstants.Json); // Assert Assert.NotEmpty(actual); diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiEncodingTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiEncodingTests.cs index fd0b21c9d..ee5b8bfd0 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiEncodingTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiEncodingTests.cs @@ -22,9 +22,9 @@ public class OpenApiEncodingTests }; [Theory] - [InlineData(OpenApiFormat.Json, "{ }")] - [InlineData(OpenApiFormat.Yaml, "{ }")] - public async Task SerializeBasicEncodingAsV3Works(OpenApiFormat format, string expected) + [InlineData(OpenApiConstants.Json, "{ }")] + [InlineData(OpenApiConstants.Yaml, "{ }")] + public async Task SerializeBasicEncodingAsV3Works(string format, string expected) { // Arrange & Act var actual = await BasicEncoding.SerializeAsync(OpenApiSpecVersion.OpenApi3_0, format); diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiExternalDocsTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiExternalDocsTests.cs index a2bee2e58..8dc551396 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiExternalDocsTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiExternalDocsTests.cs @@ -22,9 +22,9 @@ public class OpenApiExternalDocsTests #region OpenAPI V3 [Theory] - [InlineData(OpenApiFormat.Json, "{ }")] - [InlineData(OpenApiFormat.Yaml, "{ }")] - public async Task SerializeBasicExternalDocsAsV3Works(OpenApiFormat format, string expected) + [InlineData(OpenApiConstants.Json, "{ }")] + [InlineData(OpenApiConstants.Yaml, "{ }")] + public async Task SerializeBasicExternalDocsAsV3Works(string format, string expected) { // Arrange & Act var actual = await BasicExDocs.SerializeAsync(OpenApiSpecVersion.OpenApi3_0, format); diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiInfoTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiInfoTests.cs index 08300a4ff..c78c1d74f 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiInfoTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiInfoTests.cs @@ -205,7 +205,7 @@ public async Task InfoVersionShouldAcceptDateStyledAsVersions() """; // Act - var actual = await info.SerializeAsync(OpenApiSpecVersion.OpenApi3_0, OpenApiFormat.Yaml); + var actual = await info.SerializeAsync(OpenApiSpecVersion.OpenApi3_0, OpenApiConstants.Yaml); // Assert actual = actual.MakeLineBreaksEnvironmentNeutral(); diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiMediaTypeTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiMediaTypeTests.cs index 3f3c93889..6eff288ad 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiMediaTypeTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiMediaTypeTests.cs @@ -132,9 +132,9 @@ public OpenApiMediaTypeTests(ITestOutputHelper output) } [Theory] - [InlineData(OpenApiFormat.Json, "{ }")] - [InlineData(OpenApiFormat.Yaml, "{ }")] - public async Task SerializeBasicMediaTypeAsV3Works(OpenApiFormat format, string expected) + [InlineData(OpenApiConstants.Json, "{ }")] + [InlineData(OpenApiConstants.Yaml, "{ }")] + public async Task SerializeBasicMediaTypeAsV3Works(string format, string expected) { // Arrange & Act var actual = await BasicMediaType.SerializeAsync(OpenApiSpecVersion.OpenApi3_0, format); diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.cs index 51decab10..4c579fb9e 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.cs @@ -175,16 +175,16 @@ public class OpenApiResponseTests }; [Theory] - [InlineData(OpenApiSpecVersion.OpenApi3_0, OpenApiFormat.Json)] - [InlineData(OpenApiSpecVersion.OpenApi2_0, OpenApiFormat.Json)] - [InlineData(OpenApiSpecVersion.OpenApi3_0, OpenApiFormat.Yaml)] - [InlineData(OpenApiSpecVersion.OpenApi2_0, OpenApiFormat.Yaml)] + [InlineData(OpenApiSpecVersion.OpenApi3_0, OpenApiConstants.Json)] + [InlineData(OpenApiSpecVersion.OpenApi2_0, OpenApiConstants.Json)] + [InlineData(OpenApiSpecVersion.OpenApi3_0, OpenApiConstants.Yaml)] + [InlineData(OpenApiSpecVersion.OpenApi2_0, OpenApiConstants.Yaml)] public async Task SerializeBasicResponseWorks( OpenApiSpecVersion version, - OpenApiFormat format) + string format) { // Arrange - var expected = format == OpenApiFormat.Json ? @"{ + var expected = format == OpenApiConstants.Json ? @"{ ""description"": null }" : @"description: "; diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiServerVariableTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiServerVariableTests.cs index 255bfe908..2eb688edd 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiServerVariableTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiServerVariableTests.cs @@ -25,9 +25,9 @@ public class OpenApiServerVariableTests }; [Theory] - [InlineData(OpenApiFormat.Json, "{ }")] - [InlineData(OpenApiFormat.Yaml, "{ }")] - public async Task SerializeBasicServerVariableAsV3Works(OpenApiFormat format, string expected) + [InlineData(OpenApiConstants.Json, "{ }")] + [InlineData(OpenApiConstants.Yaml, "{ }")] + public async Task SerializeBasicServerVariableAsV3Works(string format, string expected) { // Arrange & Act var actual = await BasicServerVariable.SerializeAsync(OpenApiSpecVersion.OpenApi3_0, format); diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiXmlTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiXmlTests.cs index 98ec758c8..173bf6620 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiXmlTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiXmlTests.cs @@ -30,13 +30,13 @@ public class OpenApiXmlTests public static OpenApiXml BasicXml = new(); [Theory] - [InlineData(OpenApiSpecVersion.OpenApi3_0, OpenApiFormat.Json)] - [InlineData(OpenApiSpecVersion.OpenApi2_0, OpenApiFormat.Json)] - [InlineData(OpenApiSpecVersion.OpenApi3_0, OpenApiFormat.Yaml)] - [InlineData(OpenApiSpecVersion.OpenApi2_0, OpenApiFormat.Yaml)] + [InlineData(OpenApiSpecVersion.OpenApi3_0, OpenApiConstants.Json)] + [InlineData(OpenApiSpecVersion.OpenApi2_0, OpenApiConstants.Json)] + [InlineData(OpenApiSpecVersion.OpenApi3_0, OpenApiConstants.Yaml)] + [InlineData(OpenApiSpecVersion.OpenApi2_0, OpenApiConstants.Yaml)] public async Task SerializeBasicXmlWorks( OpenApiSpecVersion version, - OpenApiFormat format) + string format) { // Act var actual = await BasicXml.SerializeAsync(version, format); diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index 2ec1fb15b..53262c892 100644 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -172,13 +172,13 @@ namespace Microsoft.OpenApi.Extensions where T : Microsoft.OpenApi.Interfaces.IOpenApiSerializable { } public static System.Threading.Tasks.Task SerializeAsYamlAsync(this T element, System.IO.Stream stream, Microsoft.OpenApi.OpenApiSpecVersion specVersion, System.Threading.CancellationToken cancellationToken = default) where T : Microsoft.OpenApi.Interfaces.IOpenApiSerializable { } - public static System.Threading.Tasks.Task SerializeAsync(this T element, Microsoft.OpenApi.OpenApiSpecVersion specVersion, Microsoft.OpenApi.OpenApiFormat format, System.Threading.CancellationToken cancellationToken = default) + public static System.Threading.Tasks.Task SerializeAsync(this T element, Microsoft.OpenApi.OpenApiSpecVersion specVersion, string format, System.Threading.CancellationToken cancellationToken = default) where T : Microsoft.OpenApi.Interfaces.IOpenApiSerializable { } public static System.Threading.Tasks.Task SerializeAsync(this T element, Microsoft.OpenApi.Writers.IOpenApiWriter writer, Microsoft.OpenApi.OpenApiSpecVersion specVersion, System.Threading.CancellationToken cancellationToken = default) where T : Microsoft.OpenApi.Interfaces.IOpenApiSerializable { } - public static System.Threading.Tasks.Task SerializeAsync(this T element, System.IO.Stream stream, Microsoft.OpenApi.OpenApiSpecVersion specVersion, Microsoft.OpenApi.OpenApiFormat format, System.Threading.CancellationToken cancellationToken = default) + public static System.Threading.Tasks.Task SerializeAsync(this T element, System.IO.Stream stream, Microsoft.OpenApi.OpenApiSpecVersion specVersion, string format, System.Threading.CancellationToken cancellationToken = default) where T : Microsoft.OpenApi.Interfaces.IOpenApiSerializable { } - public static System.Threading.Tasks.Task SerializeAsync(this T element, System.IO.Stream stream, Microsoft.OpenApi.OpenApiSpecVersion specVersion, Microsoft.OpenApi.OpenApiFormat format, Microsoft.OpenApi.Writers.OpenApiWriterSettings? settings = null, System.Threading.CancellationToken cancellationToken = default) + public static System.Threading.Tasks.Task SerializeAsync(this T element, System.IO.Stream stream, Microsoft.OpenApi.OpenApiSpecVersion specVersion, string format, Microsoft.OpenApi.Writers.OpenApiWriterSettings? settings = null, System.Threading.CancellationToken cancellationToken = default) where T : Microsoft.OpenApi.Interfaces.IOpenApiSerializable { } } public static class OpenApiServerExtensions @@ -259,11 +259,6 @@ namespace Microsoft.OpenApi public string[] Tokens { get; } public override string ToString() { } } - public enum OpenApiFormat - { - Json = 0, - Yaml = 1, - } public enum OpenApiSpecVersion { OpenApi2_0 = 0, From c66f24a7f11013c43accabe29e4b6cefee605f62 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Wed, 16 Apr 2025 10:49:32 +0000 Subject: [PATCH 092/984] chore(main): release 2.0.0-preview.17 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 22 ++++++++++++++++++++++ Directory.Build.props | 2 +- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 4c324336f..d5ba1e810 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "2.0.0-preview.16" + ".": "2.0.0-preview.17" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index f590fa76d..740522c4d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,27 @@ # Changelog +## [2.0.0-preview.17](https://github.com/microsoft/OpenAPI.NET/compare/v2.0.0-preview.16...v2.0.0-preview.17) (2025-04-16) + + +### Features + +* discriminator mappings now use schema references ([b4877f6](https://github.com/microsoft/OpenAPI.NET/commit/b4877f674ad1a240a367390d40d122eebccc0b20)) +* openapiformat enum cleanup ([#2326](https://github.com/microsoft/OpenAPI.NET/issues/2326)) ([19ffd13](https://github.com/microsoft/OpenAPI.NET/commit/19ffd136a7d2137f3de0896148d9a39f469ac711)) +* Remove default collection initialization for perf reasons ([#2284](https://github.com/microsoft/OpenAPI.NET/issues/2284)) ([3604382](https://github.com/microsoft/OpenAPI.NET/commit/36043829d29340a47fc93c6477a38ea93e59ef57)) + + +### Bug Fixes + +* Empty tag causes error generating Kiota client [#2283](https://github.com/microsoft/OpenAPI.NET/issues/2283) ([#2286](https://github.com/microsoft/OpenAPI.NET/issues/2286)) ([521d636](https://github.com/microsoft/OpenAPI.NET/commit/521d636e2c437c25e1758e9f6a22793d74adf2d7)) +* hidi fails to parse yaml files when fixing references ([a5c4d61](https://github.com/microsoft/OpenAPI.NET/commit/a5c4d6109c433b949cdb1665c00ad778b82b28b0)) +* hidi fails to parse yaml files when fixing references ([c5b69fe](https://github.com/microsoft/OpenAPI.NET/commit/c5b69fed9c413a6399c36e0f543e1019faac77e6)) +* Improve handling of OpenAPI tag references ([#2325](https://github.com/microsoft/OpenAPI.NET/issues/2325)) ([bf9954a](https://github.com/microsoft/OpenAPI.NET/commit/bf9954a257691231fac6f56667bde208a98a5b42)) +* read (Exclusive)Maximum and (Exclusive)Minimum values as strings and write their raw values during serialization ([#2309](https://github.com/microsoft/OpenAPI.NET/issues/2309)) ([ac66756](https://github.com/microsoft/OpenAPI.NET/commit/ac667560a951bef2824851c208c55ba070e96163)) +* relative references in subdirectory documents are not loading [#1674](https://github.com/microsoft/OpenAPI.NET/issues/1674) ([#2243](https://github.com/microsoft/OpenAPI.NET/issues/2243)) ([4bcbd51](https://github.com/microsoft/OpenAPI.NET/commit/4bcbd51caff689a73e90efbc08f683383741e004)) +* renames annotations schema property to metadata to match [#2241](https://github.com/microsoft/OpenAPI.NET/issues/2241) ([28e4a75](https://github.com/microsoft/OpenAPI.NET/commit/28e4a7590fb3525e30970112191d72eaf048ad6b)) +* renames annotations schema property to metadata to match [#2241](https://github.com/microsoft/OpenAPI.NET/issues/2241) ([33fc7cb](https://github.com/microsoft/OpenAPI.NET/commit/33fc7cbcda71efea47070ab7a6ebf9db8787a7f8)) +* set format to binary for file uploads ([#2305](https://github.com/microsoft/OpenAPI.NET/issues/2305)) ([47f10d3](https://github.com/microsoft/OpenAPI.NET/commit/47f10d323e78b9e6caa757c0d2efa378a19fc28c)) + ## [2.0.0-preview.16](https://github.com/microsoft/OpenAPI.NET/compare/v2.0.0-preview.15...v2.0.0-preview.16) (2025-03-20) diff --git a/Directory.Build.props b/Directory.Build.props index 36d681cf5..7e245bef5 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -12,7 +12,7 @@ https://github.com/Microsoft/OpenAPI.NET © Microsoft Corporation. All rights reserved. OpenAPI .NET - 2.0.0-preview.16 + 2.0.0-preview.17 From ef6c76e5e8077bde707d4911b5e9bbc3760cde7c Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Wed, 16 Apr 2025 16:04:39 +0300 Subject: [PATCH 093/984] chore: add serialization versions for better coverage --- .../OpenApiDocumentSerializationTests .cs | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentSerializationTests .cs b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentSerializationTests .cs index 99f69168b..03724efa1 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentSerializationTests .cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentSerializationTests .cs @@ -16,8 +16,11 @@ public class OpenApiDocumentSerializationTests { private const string SampleFolderPath = "V31Tests/Samples/OpenApiDocument/"; - [Fact] - public async Task Serialize_DoesNotMutateDom() + [Theory] + [InlineData(OpenApiSpecVersion.OpenApi3_1)] + [InlineData(OpenApiSpecVersion.OpenApi3_0)] + [InlineData(OpenApiSpecVersion.OpenApi2_0)] + public async Task Serialize_DoesNotMutateDom(OpenApiSpecVersion version) { // Arrange var filePath = Path.Combine(SampleFolderPath, "docWith31properties.json"); @@ -37,7 +40,18 @@ public async Task Serialize_DoesNotMutateDom() // Serialize using native OpenAPI writer var jsonWriter = new StringWriter(); var openApiWriter = new OpenApiJsonWriter(jsonWriter); - doc.SerializeAsV31(openApiWriter); + switch (version) + { + case OpenApiSpecVersion.OpenApi3_1: + doc.SerializeAsV31(openApiWriter); + break; + case OpenApiSpecVersion.OpenApi3_0: + doc.SerializeAsV3(openApiWriter); + break; + default: + doc.SerializeAsV2(openApiWriter); + break; + } // Serialize again with STJ after native writer serialization var finalSerialized = JsonSerializer.Serialize(doc, options); From ccf8855f241f1ee6ac61f8baebecada3c078b69d Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Wed, 16 Apr 2025 12:35:15 -0400 Subject: [PATCH 094/984] ci: adds workflow dispatch to codeql workflow Signed-off-by: Vincent Biret --- .github/workflows/codeql-analysis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index e7810ec2d..e67fdc779 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -6,6 +6,7 @@ on: pull_request: schedule: - cron: '0 8 * * *' + workflow_dispatch: permissions: contents: read # these permissions are required to run the codeql analysis From 593091621926defcbc2727a922613e34557d882a Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Wed, 16 Apr 2025 13:10:13 -0400 Subject: [PATCH 095/984] fix: normalized override implementation for parameter types serialization in v2 Signed-off-by: Vincent Biret --- .../Models/OpenApiParameter.cs | 94 +++++++++++-------- 1 file changed, 54 insertions(+), 40 deletions(-) diff --git a/src/Microsoft.OpenApi/Models/OpenApiParameter.cs b/src/Microsoft.OpenApi/Models/OpenApiParameter.cs index fd74c2b57..a990ddcbb 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiParameter.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiParameter.cs @@ -165,50 +165,25 @@ internal void SerializeInternal(IOpenApiWriter writer, OpenApiSpecVersion versio writer.WriteEndObject(); } - - /// - public void SerializeAsV2(IOpenApiWriter writer) + /// + /// Write the "in" property for V2 serialization. + /// + /// Writer to use for the serialization + internal virtual void WriteInPropertyForV2(IOpenApiWriter writer) { - Utils.CheckArgumentNull(writer); - - writer.WriteStartObject(); - - // in - if (this is OpenApiFormDataParameter) - { - writer.WriteProperty(OpenApiConstants.In, "formData"); - } - else if (this is OpenApiBodyParameter) - { - writer.WriteProperty(OpenApiConstants.In, "body"); - } - else - { - writer.WriteProperty(OpenApiConstants.In, In?.GetDisplayName()); - } - - // name - writer.WriteProperty(OpenApiConstants.Name, Name); - - // description - writer.WriteProperty(OpenApiConstants.Description, Description); - - // required - writer.WriteProperty(OpenApiConstants.Required, Required, false); - - // deprecated - writer.WriteProperty(OpenApiConstants.Deprecated, Deprecated, false); - - var extensionsClone = Extensions is not null ? new Dictionary(Extensions) : null; + writer.WriteProperty(OpenApiConstants.In, In?.GetDisplayName()); + } - // schema - if (this is OpenApiBodyParameter) - { - writer.WriteOptionalObject(OpenApiConstants.Schema, Schema, (w, s) => s.SerializeAsV2(w)); - } + /// + /// Write the request body schema for V2 serialization. + /// + /// Writer to use for the serialization + /// Extensions clone + internal virtual void WriteRequestBodySchemaForV2(IOpenApiWriter writer, Dictionary? extensionsClone) + { // In V2 parameter's type can't be a reference to a custom object schema or can't be of type object // So in that case map the type as string. - else if (Schema is OpenApiSchemaReference { UnresolvedReference: true } || (Schema?.Type & JsonSchemaType.Object) == JsonSchemaType.Object) + if (Schema is OpenApiSchemaReference { UnresolvedReference: true } || (Schema?.Type & JsonSchemaType.Object) == JsonSchemaType.Object) { writer.WriteProperty(OpenApiConstants.Type, "string"); } @@ -270,7 +245,34 @@ public void SerializeAsV2(IOpenApiWriter writer) } } } + } + + /// + public void SerializeAsV2(IOpenApiWriter writer) + { + Utils.CheckArgumentNull(writer); + + writer.WriteStartObject(); + + // in + WriteInPropertyForV2(writer); + // name + writer.WriteProperty(OpenApiConstants.Name, Name); + + // description + writer.WriteProperty(OpenApiConstants.Description, Description); + + // required + writer.WriteProperty(OpenApiConstants.Required, Required, false); + + // deprecated + writer.WriteProperty(OpenApiConstants.Deprecated, Deprecated, false); + + var extensionsClone = Extensions is not null ? new Dictionary(Extensions) : null; + + // schema + WriteRequestBodySchemaForV2(writer, extensionsClone); //examples if (Examples != null && Examples.Any()) { @@ -315,6 +317,14 @@ public IOpenApiParameter CreateShallowCopy() /// internal class OpenApiBodyParameter : OpenApiParameter { + internal override void WriteRequestBodySchemaForV2(IOpenApiWriter writer, Dictionary? extensionsClone) + { + writer.WriteOptionalObject(OpenApiConstants.Schema, Schema, (w, s) => s.SerializeAsV2(w)); + } + internal override void WriteInPropertyForV2(IOpenApiWriter writer) + { + writer.WriteProperty(OpenApiConstants.In, "body"); + } } /// @@ -322,5 +332,9 @@ internal class OpenApiBodyParameter : OpenApiParameter /// internal class OpenApiFormDataParameter : OpenApiParameter { + internal override void WriteInPropertyForV2(IOpenApiWriter writer) + { + writer.WriteProperty(OpenApiConstants.In, "formData"); + } } } From 5835057a7e905e371f859e727ddaf65ec08c6db0 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Wed, 16 Apr 2025 13:13:00 -0400 Subject: [PATCH 096/984] fix: avoid calling virtual members in constructor Signed-off-by: Vincent Biret --- src/Microsoft.OpenApi/Writers/FormattingStreamWriter.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi/Writers/FormattingStreamWriter.cs b/src/Microsoft.OpenApi/Writers/FormattingStreamWriter.cs index ea4f33f63..5d24b1f3b 100644 --- a/src/Microsoft.OpenApi/Writers/FormattingStreamWriter.cs +++ b/src/Microsoft.OpenApi/Writers/FormattingStreamWriter.cs @@ -19,12 +19,13 @@ public class FormattingStreamWriter : StreamWriter public FormattingStreamWriter(Stream stream, IFormatProvider formatProvider) : base(stream) { - this.FormatProvider = formatProvider; + _formatProvider = formatProvider; } + private readonly IFormatProvider _formatProvider; /// /// The associated with this . /// - public override IFormatProvider FormatProvider { get; } + public override IFormatProvider FormatProvider { get => _formatProvider; } } } From 938a2e07b40b082e01ed1cdf3244767cbdca4061 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Thu, 17 Apr 2025 16:08:57 -0400 Subject: [PATCH 097/984] feat: upgrades openapi.net.odata and apimanifest to the latest version --- performance/resultsComparer/resultsComparer.csproj | 2 +- src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/performance/resultsComparer/resultsComparer.csproj b/performance/resultsComparer/resultsComparer.csproj index c9b715c2d..f3dd66fd3 100644 --- a/performance/resultsComparer/resultsComparer.csproj +++ b/performance/resultsComparer/resultsComparer.csproj @@ -11,7 +11,7 @@ - + diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index 1e1a8c803..1cf2489e9 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -31,15 +31,15 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all - - + + From af2d5ace2086e6e70920c3713ad59026151cea56 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 17 Apr 2025 21:39:02 +0000 Subject: [PATCH 098/984] chore(deps): bump Microsoft.OpenApi.ApiManifest and SharpYaml Bumps [Microsoft.OpenApi.ApiManifest](https://github.com/Microsoft/OpenApi.ApiManifest) and [SharpYaml](https://github.com/xoofx/SharpYaml). These dependencies needed to be updated together. Updates `Microsoft.OpenApi.ApiManifest` from 2.0.0-preview3 to 2.0.0-preview4 - [Release notes](https://github.com/Microsoft/OpenApi.ApiManifest/releases) - [Changelog](https://github.com/microsoft/OpenApi.ApiManifest/blob/main/CHANGELOG.md) - [Commits](https://github.com/Microsoft/OpenApi.ApiManifest/compare/v2.0.0-preview3...v2.0.0-preview4) Updates `SharpYaml` from 2.1.1 to 2.1.1 - [Release notes](https://github.com/xoofx/SharpYaml/releases) - [Changelog](https://github.com/xoofx/SharpYaml/blob/master/changelog.md) - [Commits](https://github.com/xoofx/SharpYaml/compare/2.1.1...2.1.1) --- updated-dependencies: - dependency-name: Microsoft.OpenApi.ApiManifest dependency-version: 2.0.0-preview4 dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: SharpYaml dependency-version: 2.1.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index 1e1a8c803..fc1a2b9a5 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -39,7 +39,7 @@ - + From 3fa7c0294f5ae47cf0e6282ce23423bfa9ff784e Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Fri, 18 Apr 2025 12:03:23 -0400 Subject: [PATCH 099/984] Update src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj --- src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index 1cf2489e9..8be5b720c 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -38,7 +38,7 @@ - + From 7608e88cdc75c90e17e72d293975649a3b527156 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Apr 2025 21:41:57 +0000 Subject: [PATCH 100/984] chore(deps): bump Verify.Xunit from 29.2.0 to 29.3.0 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 29.2.0 to 29.3.0. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/29.2.0...29.3.0) --- updated-dependencies: - dependency-name: Verify.Xunit dependency-version: 29.3.0 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 cf5736be0..e0bdeb51d 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -15,7 +15,7 @@ - + From 3efc983a090b5a1d979d8d15c5983c0f3d4aa06b Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Tue, 22 Apr 2025 18:41:04 +0300 Subject: [PATCH 101/984] chore: update upgrade guide --- docs/upgrade-guide-2.md | 154 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 139 insertions(+), 15 deletions(-) diff --git a/docs/upgrade-guide-2.md b/docs/upgrade-guide-2.md index f1fd6c23f..09bbaa124 100644 --- a/docs/upgrade-guide-2.md +++ b/docs/upgrade-guide-2.md @@ -361,6 +361,29 @@ public class OpenApiSchema : IMetadataContainer, IOpenApiExtensible, IOpenApiRef There are a number of new features in OpenAPI v3.1 that are now supported in OpenAPI.NET. +### JsonSchema Dialect and BaseUri in OpenApiDocument +To enable full compatibility with JSON Schema, the OpenApiDocument class now supports a jsonSchemaDialect property. This property specifies the JSON Schema dialect used throughout the document, using a URI. By explicitly declaring the dialect, tooling no longer needs to infer which draft is being used based on schema structure or references. + +In addition, a BaseUri property has been added to represent the absolute location of the OpenAPI document. If the document’s location is not provided, this property will be set to a generated placeholder URI. + +```csharp + /// + /// Describes an OpenAPI object (OpenAPI document). See: https://spec.openapis.org + /// + public class OpenApiDocument : IOpenApiSerializable, IOpenApiExtensible, IMetadataContainer + { + /// + /// The default value for the $schema keyword within Schema Objects contained within this OAS document. This MUST be in the form of a URI. + /// + public Uri? JsonSchemaDialect { get; set; } + + /// + /// Absolute location of the document or a generated placeholder if location is not given + /// + public Uri BaseUri { get; internal set; } + } +``` + ### Webhooks ```csharp @@ -483,6 +506,7 @@ OpenApiComponents components = new OpenApiComponents ### OpenApiDocument.SerializeAs() The `SerializeAs()` method simplifies serialization scenarios, making it easier to convert OpenAPI documents to different formats. + **Example:** ```csharp @@ -505,6 +529,120 @@ var outputString = openApiDocument.Serialize(OpenApiSpecVersion.OpenApi2_0, Open var outputString = openApiDocument.Serialize(OpenApiSpecVersion.OpenApi2_0, OpenApiConstants.Json); ``` +### OpenApiSchema's Type property is now a flaggable enum + +In v2.0, the Type property in OpenApiSchema is now defined as a flaggable enum, allowing consumers to swap nullable for type arrays. + +**Example:** +```csharp +// v1.6.x +var schema = new OpenApiSchema +{ + Type = "string", + Nullable = true +} + +// v2.0 +var schema = new OpenApiSchema +{ + Type = JsonSchemaType.String | JsonSchemaType.Null +} + +``` + +### Component registration in a document's workspace + +When loading up a file into an in-memory document, all the components contained in the document are registered within the document's workspace by default to aid with reference resolution. +However if you're working directly with a DOM and you need the references resolved, you can register the components as below: + +```csharp +// register all components +document.Workspace.RegisterComponents(OpenApiDocument document); + +// register single component +document.AddComponent(string id, T componentToRegister); +``` + +### Refactored model architecture + +The following structural improvements have been made to the OpenAPI model layer to enhance type safety, extensibility, and maintainability: + +1. Model Interfaces Introduced: +Each model now has a corresponding interface (e.g., IOpenApiSchema for OpenApiSchema). This allows for better abstraction and testing support, while also simplifying cross-cutting concerns like serialization. + +2. Models as Reference Types: +All models are now implemented as reference types to ensure consistent identity semantics, especially when managing circular references or shared definitions. + +3. Type Assertion Pattern Adopted: +A standardized pattern has been introduced for casting model instances to specific types safely and predictably, reducing the risk of invalid casts or reflection-based logic. + +4. Removed Reference Fields from Base Models: +Fields like Reference that were previously defined on base model types have been removed. Models that support referencing now handle this behavior explicitly via composition rather than inheritance. + +5. New Target and RecursiveTarget Properties: +A Target property that points to the actual resolved model instance as well as a RecursiveTarget property that handles recursive references and supports advanced dereferencing logic have been introduced. + +6. Removed OpenApiReferenceResolver: +This resolver class has been removed in favor of a more streamlined resolution model using the Target and RecursiveTarget properties along with updated reader/serializer pipelines. + +### Visitor and Validator now pass an interface model + +**Example:** +```csharp +//v1.6.x +public override void Visit(OpenApiParameter parameter){} + +//v2.0 +public override void Visit(IOpenApiParameter parameter){} +``` + +### Cleaned up the IEffective/GetEffective infrastructure + +All the IEffective and GetEffective methods in the models have been removed as we've implemented lazy reference resolution using the proxy design. + +### Shallow Copy in place of copy constructors + +Copy constructors have been eliminated from the models in favor of a more straightforward approach using a shallow copy method. This simplifies the codebase and reduces potential issues with deep copying and unintended side effects. + +**Example:** +```csharp +var schema = new OpenApiSchema(); +var schemaCopy = schema.CreateShallowCopy(); +``` + +### Duplicated _style Property on Parameter Removed + +The redundant _style property on the Parameter model has been removed to simplify the model's structure. + +### Discriminator now use References + +Discriminator mappings have been updated from using a Dictionary to a Dictionary. This change improves the handling of discriminator mappings by referencing OpenAPI schema components more explicitly, which enhances schema resolution. + +**Example:** +```csharp +// v1.6.x +Discriminator = new() +{ + PropertyName = "@odata.type", + Mapping = new Dictionary { + { + "#microsoft.graph.directoryObject", "#/components/schemas/microsoft.graph.directoryObject" + } + } +} + +//v2.0 +Discriminator = new()public string? ExclusiveMaximum +{ + PropertyName = "@odata.type", + Mapping = new Dictionary { + { + "#microsoft.graph.directoryObject", new OpenApiSchemaReference("microsoft.graph.directoryObject") + } + } +} +``` + ### Bug Fixes ## Serialization of References @@ -523,18 +661,4 @@ OpenApiSchemaReference schemaRef = new OpenApiSchemaReference("MySchema") ## Feedback If you have any feedback please file a GitHub issue [here](https://github.com/microsoft/OpenAPI.NET/issues) -The team is looking forward to hear your experience trying the new version and we hope you have fun busting out your OpenAPI 3.1 descriptions. - -## Todos - -- Models now have matching interfaces + reference type + type assertion pattern + reference fields removed from the base model + Target + RecursiveTarget + removed OpenApiReferenceResolver. -- Workspace + component resolution. -- Visitor and Validator method now pass the interface model. -- Removed all the IEffective/GetEffective infrastructure. -- OpenApiSchema.Type is now a flag enum + bitwise operations. -- JsonSchemaDialect + BaseUri in document. -- Copy constructors are gone, use shallow copy method. -- Multiple methods that should have been internal have been changed from public to private link OpenApiLink.SerializeAsV3WithoutReference. -- duplicated _style property on parameter was removed. -- discriminator now uses references. -- ValidationRuleSet now accepts a key? \ No newline at end of file +The team is looking forward to hear your experience trying the new version and we hope you have fun busting out your OpenAPI 3.1 descriptions. \ No newline at end of file From 84a6e2b1534002b961a14ce20ad4831bef1cbab1 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Tue, 22 Apr 2025 18:43:07 +0300 Subject: [PATCH 102/984] chore: fix formatting --- docs/upgrade-guide-2.md | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/docs/upgrade-guide-2.md b/docs/upgrade-guide-2.md index 09bbaa124..7dac8c1d7 100644 --- a/docs/upgrade-guide-2.md +++ b/docs/upgrade-guide-2.md @@ -367,21 +367,21 @@ To enable full compatibility with JSON Schema, the OpenApiDocument class now sup In addition, a BaseUri property has been added to represent the absolute location of the OpenAPI document. If the document’s location is not provided, this property will be set to a generated placeholder URI. ```csharp +/// +/// Describes an OpenAPI object (OpenAPI document). See: https://spec.openapis.org +/// +public class OpenApiDocument : IOpenApiSerializable, IOpenApiExtensible, IMetadataContainer +{ /// - /// Describes an OpenAPI object (OpenAPI document). See: https://spec.openapis.org + /// The default value for the $schema keyword within Schema Objects contained within this OAS document. This MUST be in the form of a URI. /// - public class OpenApiDocument : IOpenApiSerializable, IOpenApiExtensible, IMetadataContainer - { - /// - /// The default value for the $schema keyword within Schema Objects contained within this OAS document. This MUST be in the form of a URI. - /// - public Uri? JsonSchemaDialect { get; set; } - - /// - /// Absolute location of the document or a generated placeholder if location is not given - /// - public Uri BaseUri { get; internal set; } - } + public Uri? JsonSchemaDialect { get; set; } + + /// + /// Absolute location of the document or a generated placeholder if location is not given + /// + public Uri BaseUri { get; internal set; } +} ``` ### Webhooks From 5e65689d477fd490d1e830fb326425d06102ab5e Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Wed, 23 Apr 2025 15:52:02 +0300 Subject: [PATCH 103/984] Update docs/upgrade-guide-2.md Co-authored-by: Darrel --- docs/upgrade-guide-2.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/upgrade-guide-2.md b/docs/upgrade-guide-2.md index 7dac8c1d7..84d4e97d8 100644 --- a/docs/upgrade-guide-2.md +++ b/docs/upgrade-guide-2.md @@ -362,7 +362,7 @@ public class OpenApiSchema : IMetadataContainer, IOpenApiExtensible, IOpenApiRef There are a number of new features in OpenAPI v3.1 that are now supported in OpenAPI.NET. ### JsonSchema Dialect and BaseUri in OpenApiDocument -To enable full compatibility with JSON Schema, the OpenApiDocument class now supports a jsonSchemaDialect property. This property specifies the JSON Schema dialect used throughout the document, using a URI. By explicitly declaring the dialect, tooling no longer needs to infer which draft is being used based on schema structure or references. +To enable full compatibility with JSON Schema, the OpenApiDocument class now supports a jsonSchemaDialect property. This property specifies the JSON Schema dialect used throughout the document, using a URI. By explicitly declaring the dialect, tooling can be directed to use a JSON Schema version other than the default [2020-12 draft](https://json-schema.org/draft/2020-12/json-schema-core.html). However, OpenAPI.NET does not guarantee compatibility with versions other than 2020-12. In addition, a BaseUri property has been added to represent the absolute location of the OpenAPI document. If the document’s location is not provided, this property will be set to a generated placeholder URI. From eb157d99787e0b1583946385a89357bd248908f8 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Wed, 23 Apr 2025 16:34:09 +0300 Subject: [PATCH 104/984] Update docs/upgrade-guide-2.md Co-authored-by: Darrel --- docs/upgrade-guide-2.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/upgrade-guide-2.md b/docs/upgrade-guide-2.md index 84d4e97d8..cd9d485aa 100644 --- a/docs/upgrade-guide-2.md +++ b/docs/upgrade-guide-2.md @@ -364,7 +364,7 @@ There are a number of new features in OpenAPI v3.1 that are now supported in Ope ### JsonSchema Dialect and BaseUri in OpenApiDocument To enable full compatibility with JSON Schema, the OpenApiDocument class now supports a jsonSchemaDialect property. This property specifies the JSON Schema dialect used throughout the document, using a URI. By explicitly declaring the dialect, tooling can be directed to use a JSON Schema version other than the default [2020-12 draft](https://json-schema.org/draft/2020-12/json-schema-core.html). However, OpenAPI.NET does not guarantee compatibility with versions other than 2020-12. -In addition, a BaseUri property has been added to represent the absolute location of the OpenAPI document. If the document’s location is not provided, this property will be set to a generated placeholder URI. +In addition, a BaseUri property has been added to represent the identity of the OpenAPI document. If the document’s identity is not provided or cannot be determined at based on its location, this property will be set to a generated placeholder URI. ```csharp /// From 8c9559e54c805c3f3c206ef68fd24f43f23297ed Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Wed, 23 Apr 2025 16:38:38 +0300 Subject: [PATCH 105/984] chore: update doc --- docs/upgrade-guide-2.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/upgrade-guide-2.md b/docs/upgrade-guide-2.md index 84d4e97d8..9473777b4 100644 --- a/docs/upgrade-guide-2.md +++ b/docs/upgrade-guide-2.md @@ -602,7 +602,7 @@ All the IEffective and GetEffective methods in the models have been removed as w ### Shallow Copy in place of copy constructors -Copy constructors have been eliminated from the models in favor of a more straightforward approach using a shallow copy method. This simplifies the codebase and reduces potential issues with deep copying and unintended side effects. +Copy constructors for referenceable components have been made internal, a new *CreateShallowCopy()* method has been exposed on these models to facilitate deep copying. **Example:** ```csharp From ec467743ff2d36be5b10962e452b2cdaec253b3d Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Wed, 23 Apr 2025 19:07:42 +0300 Subject: [PATCH 106/984] chore: rename OpenApiAny to JsonNodeExtension --- .../Extensions/OpenApiExtensibleExtensions.cs | 4 +- .../JsonNodeExtension.cs} | 10 ++--- .../OpenApiDeprecationExtension.cs | 3 +- .../OpenApiPrimaryErrorMessageExtension.cs | 4 +- .../OpenApiReservedParameterExtension.cs | 4 +- .../Models/OpenApiRequestBody.cs | 3 +- src/Microsoft.OpenApi/Models/OpenApiSchema.cs | 3 +- .../ParseNodes/AnyMapFieldMapParameter.cs | 2 +- .../Reader/ParseNodes/MapNode.cs | 4 +- .../Reader/V2/OpenApiOperationDeserializer.cs | 4 +- .../Reader/V2/OpenApiV2Deserializer.cs | 4 +- .../Reader/V2/OpenApiV2VersionService.cs | 4 +- .../Reader/V3/OpenApiV3Deserializer.cs | 8 ++-- .../Reader/V3/OpenApiV3VersionService.cs | 4 +- .../Reader/V31/OpenApiV31Deserializer.cs | 4 +- .../Reader/V31/OpenApiV31VersionService.cs | 4 +- .../Services/OpenApiWalker.cs | 3 +- .../Writers/OpenApiWriterAnyExtensions.cs | 4 +- .../Formatters/PowerShellFormatterTests.cs | 6 +-- .../UtilityFiles/OpenApiDocumentMock.cs | 13 +++---- .../V2Tests/OpenApiDocumentTests.cs | 4 +- .../V2Tests/OpenApiHeaderTests.cs | 10 ++--- .../V2Tests/OpenApiOperationTests.cs | 4 +- .../V2Tests/OpenApiParameterTests.cs | 10 ++--- .../V2Tests/OpenApiSchemaTests.cs | 8 ++-- .../V3Tests/OpenApiInfoTests.cs | 38 +++++++++---------- .../V3Tests/OpenApiSchemaTests.cs | 13 +++---- .../OpenApiDeprecationExtensionTests.cs | 1 - .../OpenApiPagingExtensionsTests.cs | 8 ++-- .../Models/OpenApiContactTests.cs | 5 +-- .../Models/OpenApiDocumentTests.cs | 20 +++++----- .../Models/OpenApiInfoTests.cs | 4 +- .../Models/OpenApiLicenseTests.cs | 5 +-- .../Models/OpenApiLinkTests.cs | 5 +-- .../Models/OpenApiParameterTests.cs | 10 ++--- .../Models/OpenApiResponseTests.cs | 7 +--- .../Models/OpenApiSchemaTests.cs | 6 +-- .../Models/OpenApiXmlTests.cs | 5 +-- .../PublicApi/PublicApi.approved.txt | 15 +++----- .../Services/OpenApiValidatorTests.cs | 12 +++--- .../OpenApiSchemaValidationTests.cs | 10 ++--- .../Validations/OpenApiTagValidationTests.cs | 4 +- .../Writers/OpenApiJsonWriterTests.cs | 9 ++--- 43 files changed, 135 insertions(+), 173 deletions(-) rename src/Microsoft.OpenApi/{Any/OpenApiAny.cs => Extensions/JsonNodeExtension.cs} (76%) diff --git a/src/Microsoft.OpenApi.Hidi/Extensions/OpenApiExtensibleExtensions.cs b/src/Microsoft.OpenApi.Hidi/Extensions/OpenApiExtensibleExtensions.cs index 368b67e8c..1287e704d 100644 --- a/src/Microsoft.OpenApi.Hidi/Extensions/OpenApiExtensibleExtensions.cs +++ b/src/Microsoft.OpenApi.Hidi/Extensions/OpenApiExtensibleExtensions.cs @@ -1,4 +1,4 @@ -using Microsoft.OpenApi.Any; +using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Interfaces; using System.Collections.Generic; using System.Text.Json.Nodes; @@ -15,7 +15,7 @@ internal static class OpenApiExtensibleExtensions /// A value matching the provided extensionKey. Return null when extensionKey is not found. internal static string GetExtension(this Dictionary extensions, string extensionKey) { - if (extensions.TryGetValue(extensionKey, out var value) && value is OpenApiAny { Node: JsonValue castValue } && castValue.TryGetValue(out var stringValue)) + if (extensions.TryGetValue(extensionKey, out var value) && value is JsonNodeExtension { Node: JsonValue castValue } && castValue.TryGetValue(out var stringValue)) { return stringValue; } diff --git a/src/Microsoft.OpenApi/Any/OpenApiAny.cs b/src/Microsoft.OpenApi/Extensions/JsonNodeExtension.cs similarity index 76% rename from src/Microsoft.OpenApi/Any/OpenApiAny.cs rename to src/Microsoft.OpenApi/Extensions/JsonNodeExtension.cs index 54bddf326..d0598f592 100644 --- a/src/Microsoft.OpenApi/Any/OpenApiAny.cs +++ b/src/Microsoft.OpenApi/Extensions/JsonNodeExtension.cs @@ -5,20 +5,20 @@ using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Writers; -namespace Microsoft.OpenApi.Any +namespace Microsoft.OpenApi.Extensions { /// /// A wrapper class for JsonNode /// - public class OpenApiAny : IOpenApiElement, IOpenApiExtension + public class JsonNodeExtension : IOpenApiElement, IOpenApiExtension { private readonly JsonNode jsonNode; /// - /// Initializes the class. + /// Initializes the class. /// /// - public OpenApiAny(JsonNode jsonNode) + public JsonNodeExtension(JsonNode jsonNode) { this.jsonNode = jsonNode; } @@ -29,7 +29,7 @@ public OpenApiAny(JsonNode jsonNode) public JsonNode Node { get { return jsonNode; } } /// - /// Writes out the OpenApiAny type. + /// Writes out the JsonNodeExtension type. /// /// /// diff --git a/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiDeprecationExtension.cs b/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiDeprecationExtension.cs index a61d93ce4..446751799 100644 --- a/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiDeprecationExtension.cs +++ b/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiDeprecationExtension.cs @@ -5,7 +5,6 @@ using System; using Microsoft.OpenApi.Extensions; -using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Writers; using System.Text.Json.Nodes; @@ -103,7 +102,7 @@ jsonNode is not JsonValue jsonValue || return null; } /// - /// Parses the to . + /// Parses the to . /// /// The source object. /// The . diff --git a/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiPrimaryErrorMessageExtension.cs b/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiPrimaryErrorMessageExtension.cs index aabcf0d26..96185ae60 100644 --- a/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiPrimaryErrorMessageExtension.cs +++ b/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiPrimaryErrorMessageExtension.cs @@ -5,7 +5,7 @@ using System; using System.Text.Json.Nodes; -using Microsoft.OpenApi.Any; +using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Writers; @@ -34,7 +34,7 @@ public void Write(IOpenApiWriter writer, OpenApiSpecVersion specVersion) public bool IsPrimaryErrorMessage { get; set; } /// - /// Parses the to . + /// Parses the to . /// /// The source object. /// The . diff --git a/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiReservedParameterExtension.cs b/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiReservedParameterExtension.cs index eb58c1e5c..2b3d22e42 100644 --- a/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiReservedParameterExtension.cs +++ b/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiReservedParameterExtension.cs @@ -5,7 +5,7 @@ using System; using System.Text.Json.Nodes; -using Microsoft.OpenApi.Any; +using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Writers; @@ -35,7 +35,7 @@ public bool? IsReserved get; set; } /// - /// Parses the to . + /// Parses the to . /// /// The source object. /// The . diff --git a/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs b/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs index 302cfc5ae..7072b2530 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs @@ -4,7 +4,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.Models.Interfaces; @@ -110,7 +109,7 @@ public IOpenApiParameter ConvertToBodyParameter(IOpenApiWriter writer) // Clone extensions so we can remove the x-bodyName extensions from the output V2 model. if (bodyParameter.Extensions is not null && bodyParameter.Extensions.TryGetValue(OpenApiConstants.BodyName, out var bodyNameExtension) && - bodyNameExtension is OpenApiAny bodyName) + bodyNameExtension is JsonNodeExtension bodyName) { bodyParameter.Name = string.IsNullOrEmpty(bodyName.Node.ToString()) ? "body" : bodyName.Node.ToString(); bodyParameter.Extensions.Remove(OpenApiConstants.BodyName); diff --git a/src/Microsoft.OpenApi/Models/OpenApiSchema.cs b/src/Microsoft.OpenApi/Models/OpenApiSchema.cs index 94d0d9299..efbd3a2eb 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiSchema.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiSchema.cs @@ -6,7 +6,6 @@ using System.Linq; using System.Text.Json; using System.Text.Json.Nodes; -using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Helpers; using Microsoft.OpenApi.Interfaces; @@ -755,7 +754,7 @@ private void SerializeTypeProperty(JsonSchemaType? type, IOpenApiWriter writer, var isNullable = (Type.HasValue && Type.Value.HasFlag(JsonSchemaType.Null)) || Extensions is not null && Extensions.TryGetValue(OpenApiConstants.NullableExtension, out var nullExtRawValue) && - nullExtRawValue is OpenApiAny { Node: JsonNode jsonNode } && + nullExtRawValue is JsonNodeExtension { Node: JsonNode jsonNode } && jsonNode.GetValueKind() is JsonValueKind.True; if (type is null) { diff --git a/src/Microsoft.OpenApi/Reader/ParseNodes/AnyMapFieldMapParameter.cs b/src/Microsoft.OpenApi/Reader/ParseNodes/AnyMapFieldMapParameter.cs index 883aa137b..1bbb387dd 100644 --- a/src/Microsoft.OpenApi/Reader/ParseNodes/AnyMapFieldMapParameter.cs +++ b/src/Microsoft.OpenApi/Reader/ParseNodes/AnyMapFieldMapParameter.cs @@ -27,7 +27,7 @@ public AnyMapFieldMapParameter( } /// - /// Function to retrieve the property that is a map from string to an inner element containing IOpenApiAny. + /// Function to retrieve the property that is a map from string to an inner element. /// public Func?> PropertyMapGetter { get; } diff --git a/src/Microsoft.OpenApi/Reader/ParseNodes/MapNode.cs b/src/Microsoft.OpenApi/Reader/ParseNodes/MapNode.cs index ae7adefa6..f16807701 100644 --- a/src/Microsoft.OpenApi/Reader/ParseNodes/MapNode.cs +++ b/src/Microsoft.OpenApi/Reader/ParseNodes/MapNode.cs @@ -9,8 +9,8 @@ using System.Text.Json; using System.Text.Json.Nodes; using System.Text.Json.Serialization; -using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Exceptions; +using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; namespace Microsoft.OpenApi.Reader.ParseNodes @@ -191,7 +191,7 @@ public override string GetRaw() } /// - /// Create an + /// Create an /// /// The created Json object. public override JsonNode CreateAny() diff --git a/src/Microsoft.OpenApi/Reader/V2/OpenApiOperationDeserializer.cs b/src/Microsoft.OpenApi/Reader/V2/OpenApiOperationDeserializer.cs index 4e53273e8..ebea2bc40 100644 --- a/src/Microsoft.OpenApi/Reader/V2/OpenApiOperationDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V2/OpenApiOperationDeserializer.cs @@ -3,14 +3,12 @@ using System.Collections.Generic; using System.Linq; -using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Reader.ParseNodes; using Microsoft.OpenApi.Models.References; using Microsoft.OpenApi.Models.Interfaces; using System; -using Microsoft.OpenApi.Interfaces; namespace Microsoft.OpenApi.Reader.V2 { @@ -242,7 +240,7 @@ internal static IOpenApiRequestBody CreateRequestBody( if (bodyParameter.Name is not null) { requestBody.Extensions ??= []; - requestBody.Extensions[OpenApiConstants.BodyName] = new OpenApiAny(bodyParameter.Name); + requestBody.Extensions[OpenApiConstants.BodyName] = new JsonNodeExtension(bodyParameter.Name); } return requestBody; } diff --git a/src/Microsoft.OpenApi/Reader/V2/OpenApiV2Deserializer.cs b/src/Microsoft.OpenApi/Reader/V2/OpenApiV2Deserializer.cs index dc347615e..c791d1f56 100644 --- a/src/Microsoft.OpenApi/Reader/V2/OpenApiV2Deserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V2/OpenApiV2Deserializer.cs @@ -5,8 +5,8 @@ using System.Collections.Generic; using System.Linq; using System.Text.Json.Nodes; -using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Exceptions; +using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Reader.ParseNodes; @@ -86,7 +86,7 @@ private static IOpenApiExtension LoadExtension(string name, ParseNode node) } else { - return new OpenApiAny(node.CreateAny()); + return new JsonNodeExtension(node.CreateAny()); } } diff --git a/src/Microsoft.OpenApi/Reader/V2/OpenApiV2VersionService.cs b/src/Microsoft.OpenApi/Reader/V2/OpenApiV2VersionService.cs index ec46036e0..354358ca6 100644 --- a/src/Microsoft.OpenApi/Reader/V2/OpenApiV2VersionService.cs +++ b/src/Microsoft.OpenApi/Reader/V2/OpenApiV2VersionService.cs @@ -3,8 +3,8 @@ using System; using System.Collections.Generic; -using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Exceptions; +using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Properties; @@ -31,7 +31,7 @@ public OpenApiV2VersionService(OpenApiDiagnostic diagnostic) private readonly Dictionary> _loaders = new() { - [typeof(OpenApiAny)] = OpenApiV2Deserializer.LoadAny, + [typeof(JsonNodeExtension)] = OpenApiV2Deserializer.LoadAny, [typeof(OpenApiContact)] = OpenApiV2Deserializer.LoadContact, [typeof(OpenApiExternalDocs)] = OpenApiV2Deserializer.LoadExternalDocs, [typeof(OpenApiHeader)] = OpenApiV2Deserializer.LoadHeader, diff --git a/src/Microsoft.OpenApi/Reader/V3/OpenApiV3Deserializer.cs b/src/Microsoft.OpenApi/Reader/V3/OpenApiV3Deserializer.cs index 29eb3db70..4049fe0c0 100644 --- a/src/Microsoft.OpenApi/Reader/V3/OpenApiV3Deserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V3/OpenApiV3Deserializer.cs @@ -5,9 +5,9 @@ using System.Collections.Generic; using System.Linq; using System.Text.Json.Nodes; -using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Exceptions; using Microsoft.OpenApi.Expressions; +using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Reader.ParseNodes; @@ -131,9 +131,9 @@ private static RuntimeExpressionAnyWrapper LoadRuntimeExpressionAnyWrapper(Parse }; } - public static OpenApiAny LoadAny(ParseNode node, OpenApiDocument hostDocument) + public static JsonNodeExtension LoadAny(ParseNode node, OpenApiDocument hostDocument) { - return new OpenApiAny(node.CreateAny()); + return new JsonNodeExtension(node.CreateAny()); } private static IOpenApiExtension LoadExtension(string name, ParseNode node) @@ -145,7 +145,7 @@ private static IOpenApiExtension LoadExtension(string name, ParseNode node) } else { - return new OpenApiAny(node.CreateAny()); + return new JsonNodeExtension(node.CreateAny()); } } diff --git a/src/Microsoft.OpenApi/Reader/V3/OpenApiV3VersionService.cs b/src/Microsoft.OpenApi/Reader/V3/OpenApiV3VersionService.cs index 34ad86fe3..cfbf30bae 100644 --- a/src/Microsoft.OpenApi/Reader/V3/OpenApiV3VersionService.cs +++ b/src/Microsoft.OpenApi/Reader/V3/OpenApiV3VersionService.cs @@ -4,7 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; -using Microsoft.OpenApi.Any; +using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.References; @@ -32,7 +32,7 @@ public OpenApiV3VersionService(OpenApiDiagnostic diagnostic) private readonly Dictionary> _loaders = new() { - [typeof(OpenApiAny)] = OpenApiV3Deserializer.LoadAny, + [typeof(JsonNodeExtension)] = OpenApiV3Deserializer.LoadAny, [typeof(OpenApiCallback)] = OpenApiV3Deserializer.LoadCallback, [typeof(OpenApiComponents)] = OpenApiV3Deserializer.LoadComponents, [typeof(OpenApiContact)] = OpenApiV3Deserializer.LoadContact, diff --git a/src/Microsoft.OpenApi/Reader/V31/OpenApiV31Deserializer.cs b/src/Microsoft.OpenApi/Reader/V31/OpenApiV31Deserializer.cs index 4ecb26bf7..9b871863f 100644 --- a/src/Microsoft.OpenApi/Reader/V31/OpenApiV31Deserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V31/OpenApiV31Deserializer.cs @@ -4,9 +4,9 @@ using System; using System.Linq; using System.Text.Json.Nodes; -using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Exceptions; using Microsoft.OpenApi.Expressions; +using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Reader.ParseNodes; @@ -139,7 +139,7 @@ private static IOpenApiExtension LoadExtension(string name, ParseNode node) { return node.Context.ExtensionParsers is not null && node.Context.ExtensionParsers.TryGetValue(name, out var parser) ? parser(node.CreateAny(), OpenApiSpecVersion.OpenApi3_1) - : new OpenApiAny(node.CreateAny()); + : new JsonNodeExtension(node.CreateAny()); } private static string? LoadString(ParseNode node) diff --git a/src/Microsoft.OpenApi/Reader/V31/OpenApiV31VersionService.cs b/src/Microsoft.OpenApi/Reader/V31/OpenApiV31VersionService.cs index 90d8e86aa..648fcc93e 100644 --- a/src/Microsoft.OpenApi/Reader/V31/OpenApiV31VersionService.cs +++ b/src/Microsoft.OpenApi/Reader/V31/OpenApiV31VersionService.cs @@ -4,7 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; -using Microsoft.OpenApi.Any; +using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.References; @@ -31,7 +31,7 @@ public OpenApiV31VersionService(OpenApiDiagnostic diagnostic) private readonly Dictionary> _loaders = new Dictionary> { - [typeof(OpenApiAny)] = OpenApiV31Deserializer.LoadAny, + [typeof(JsonNodeExtension)] = OpenApiV31Deserializer.LoadAny, [typeof(OpenApiCallback)] = OpenApiV31Deserializer.LoadCallback, [typeof(OpenApiComponents)] = OpenApiV31Deserializer.LoadComponents, [typeof(OpenApiContact)] = OpenApiV31Deserializer.LoadContact, diff --git a/src/Microsoft.OpenApi/Services/OpenApiWalker.cs b/src/Microsoft.OpenApi/Services/OpenApiWalker.cs index c0cc15979..56eea541a 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiWalker.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiWalker.cs @@ -6,7 +6,6 @@ using System.Linq; using System.Net.Http; using System.Text.Json.Nodes; -using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; @@ -965,7 +964,7 @@ internal void Walk(Dictionary? examples) } /// - /// Visits and child objects + /// Visits and child objects /// internal void Walk(JsonNode? example) { diff --git a/src/Microsoft.OpenApi/Writers/OpenApiWriterAnyExtensions.cs b/src/Microsoft.OpenApi/Writers/OpenApiWriterAnyExtensions.cs index 09ee79309..4e46c5bf1 100644 --- a/src/Microsoft.OpenApi/Writers/OpenApiWriterAnyExtensions.cs +++ b/src/Microsoft.OpenApi/Writers/OpenApiWriterAnyExtensions.cs @@ -6,13 +6,13 @@ using System.Globalization; using System.Text.Json; using System.Text.Json.Nodes; -using Microsoft.OpenApi.Any; +using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Interfaces; namespace Microsoft.OpenApi.Writers { /// - /// Extensions methods for writing the + /// Extensions methods for writing the /// public static class OpenApiWriterAnyExtensions { diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Formatters/PowerShellFormatterTests.cs b/test/Microsoft.OpenApi.Hidi.Tests/Formatters/PowerShellFormatterTests.cs index 7b3cd338e..0e618ba1b 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Formatters/PowerShellFormatterTests.cs +++ b/test/Microsoft.OpenApi.Hidi.Tests/Formatters/PowerShellFormatterTests.cs @@ -1,8 +1,6 @@ -using Microsoft.OpenApi.Any; +using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Hidi.Formatters; -using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; -using Microsoft.OpenApi.Models.Interfaces; using Microsoft.OpenApi.Services; using Xunit; @@ -147,7 +145,7 @@ private static OpenApiDocument GetSampleOpenApiDocument() Extensions = new() { { - "x-ms-docs-operation-type", new OpenApiAny("function") + "x-ms-docs-operation-type", new JsonNodeExtension("function") } } } diff --git a/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/OpenApiDocumentMock.cs b/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/OpenApiDocumentMock.cs index 421cecdd7..3335f6b7f 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/OpenApiDocumentMock.cs +++ b/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/OpenApiDocumentMock.cs @@ -1,8 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. -using Microsoft.OpenApi.Any; -using Microsoft.OpenApi.Interfaces; +using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.Interfaces; using Microsoft.OpenApi.Models.References; @@ -475,7 +474,7 @@ public static OpenApiDocument CreateOpenApiDocument() Extensions = new() { { - "x-ms-docs-key-type", new OpenApiAny("call") + "x-ms-docs-key-type", new JsonNodeExtension("call") } } } @@ -492,7 +491,7 @@ public static OpenApiDocument CreateOpenApiDocument() Extensions = new() { { - "x-ms-docs-operation-type", new OpenApiAny("action") + "x-ms-docs-operation-type", new JsonNodeExtension("action") } } } @@ -523,7 +522,7 @@ public static OpenApiDocument CreateOpenApiDocument() Extensions = new() { { - "x-ms-docs-key-type", new OpenApiAny("group") + "x-ms-docs-key-type", new JsonNodeExtension("group") } } }, @@ -540,7 +539,7 @@ public static OpenApiDocument CreateOpenApiDocument() Extensions = new() { { - "x-ms-docs-key-type", new OpenApiAny("event") + "x-ms-docs-key-type", new JsonNodeExtension("event") } } } @@ -579,7 +578,7 @@ public static OpenApiDocument CreateOpenApiDocument() Extensions = new() { { - "x-ms-docs-operation-type", new OpenApiAny("function") + "x-ms-docs-operation-type", new JsonNodeExtension("function") } } } diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs index d6daa59d8..c557ade80 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs @@ -9,7 +9,7 @@ using System.Threading.Tasks; using FluentAssertions; using FluentAssertions.Equivalency; -using Microsoft.OpenApi.Any; +using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.Interfaces; using Microsoft.OpenApi.Models.References; @@ -55,7 +55,7 @@ public void ParseDocumentWithDifferentCultureShouldSucceed(string culture) "yaml", SettingsFixture.ReaderSettings); Assert.Equal("0.9.1", result.Document.Info.Version, StringComparer.OrdinalIgnoreCase); - var extension = Assert.IsType(result.Document.Info.Extensions["x-extension"]); + var extension = Assert.IsType(result.Document.Info.Extensions["x-extension"]); Assert.Equal(2.335M, extension.Node.GetValue()); var sampleSchema = Assert.IsType(result.Document.Components.Schemas["sampleSchema"]); var samplePropertySchema = Assert.IsType(sampleSchema.Properties["sampleProperty"]); diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiHeaderTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiHeaderTests.cs index 86ebfcab2..62de886f5 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiHeaderTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiHeaderTests.cs @@ -4,7 +4,7 @@ using System.IO; using FluentAssertions; using FluentAssertions.Equivalency; -using Microsoft.OpenApi.Any; +using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Reader.ParseNodes; using Microsoft.OpenApi.Reader.V2; @@ -38,7 +38,7 @@ public void ParseHeaderWithDefaultShouldSucceed() { Type = JsonSchemaType.Number, Format = "float", - Default = new OpenApiAny(5).Node + Default = new JsonNodeExtension(5).Node } }, options => options @@ -69,9 +69,9 @@ public void ParseHeaderWithEnumShouldSucceed() Format = "float", Enum = [ - new OpenApiAny(7).Node, - new OpenApiAny(8).Node, - new OpenApiAny(9).Node + new JsonNodeExtension(7).Node, + new JsonNodeExtension(8).Node, + new JsonNodeExtension(9).Node ] } }, options => options.IgnoringCyclicReferences() diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs index 3d40535c6..811feec75 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs @@ -8,9 +8,7 @@ using System.Text.Json.Nodes; using System.Threading.Tasks; using FluentAssertions; -using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Extensions; -using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.Interfaces; using Microsoft.OpenApi.Models.References; @@ -96,7 +94,7 @@ public class OpenApiOperationTests }, Extensions = new() { - [OpenApiConstants.BodyName] = new OpenApiAny("petObject") + [OpenApiConstants.BodyName] = new JsonNodeExtension("petObject") } }, Responses = new OpenApiResponses diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiParameterTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiParameterTests.cs index 6e8685c4b..30d805c66 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiParameterTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiParameterTests.cs @@ -4,7 +4,7 @@ using System.IO; using FluentAssertions; using FluentAssertions.Equivalency; -using Microsoft.OpenApi.Any; +using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Reader.ParseNodes; using Microsoft.OpenApi.Reader.V2; @@ -239,7 +239,7 @@ public void ParseParameterWithDefaultShouldSucceed() { Type = JsonSchemaType.Number, Format = "float", - Default = new OpenApiAny(5).Node + Default = new JsonNodeExtension(5).Node } }, options => options.IgnoringCyclicReferences().Excluding(x => x.Schema.Default.Parent)); } @@ -268,9 +268,9 @@ public void ParseParameterWithEnumShouldSucceed() Format = "float", Enum = [ - new OpenApiAny(7).Node, - new OpenApiAny(8).Node, - new OpenApiAny(9).Node + new JsonNodeExtension(7).Node, + new JsonNodeExtension(8).Node, + new JsonNodeExtension(9).Node ] } }; diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSchemaTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSchemaTests.cs index 68f41271a..b4dfae059 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSchemaTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSchemaTests.cs @@ -7,7 +7,7 @@ using Xunit; using Microsoft.OpenApi.Reader.ParseNodes; using Microsoft.OpenApi.Models; -using Microsoft.OpenApi.Any; +using Microsoft.OpenApi.Extensions; using System.Text.Json.Nodes; using System.Collections.Generic; using FluentAssertions.Equivalency; @@ -87,9 +87,9 @@ public void ParseSchemaWithEnumShouldSucceed() Format = "float", Enum = [ - new OpenApiAny(7).Node, - new OpenApiAny(8).Node, - new OpenApiAny(9).Node + new JsonNodeExtension(7).Node, + new JsonNodeExtension(8).Node, + new JsonNodeExtension(9).Node ] }; diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiInfoTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiInfoTests.cs index fd7c5e478..94bc24012 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiInfoTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiInfoTests.cs @@ -7,7 +7,7 @@ using System.Text.Json.Nodes; using System.Threading.Tasks; using FluentAssertions; -using Microsoft.OpenApi.Any; +using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Reader; @@ -39,7 +39,7 @@ public async Task ParseAdvancedInfoShouldSucceed() Email = "example@example.com", Extensions = new Dictionary { - ["x-twitter"] = new OpenApiAny("@exampleTwitterHandler") + ["x-twitter"] = new JsonNodeExtension("@exampleTwitterHandler") }, Name = "John Doe", Url = new Uri("http://www.example.com/url1") @@ -48,36 +48,36 @@ public async Task ParseAdvancedInfoShouldSucceed() { Extensions = new Dictionary { - ["x-disclaimer"] = new OpenApiAny("Sample Extension String Disclaimer") + ["x-disclaimer"] = new JsonNodeExtension("Sample Extension String Disclaimer") }, Name = "licenseName", Url = new Uri("http://www.example.com/url2") }, Extensions = new Dictionary { - ["x-something"] = new OpenApiAny("Sample Extension String Something"), - ["x-contact"] = new OpenApiAny(new JsonObject() + ["x-something"] = new JsonNodeExtension("Sample Extension String Something"), + ["x-contact"] = new JsonNodeExtension(new JsonObject() { ["name"] = "John Doe", ["url"] = "http://www.example.com/url3", ["email"] = "example@example.com" }), - ["x-list"] = new OpenApiAny (new JsonArray { "1", "2" }) + ["x-list"] = new JsonNodeExtension (new JsonArray { "1", "2" }) } }, options => options.IgnoringCyclicReferences() - .Excluding(i => ((OpenApiAny)i.Contact.Extensions["x-twitter"]).Node.Parent) - .Excluding(i => ((OpenApiAny)i.License.Extensions["x-disclaimer"]).Node.Parent) - .Excluding(i => ((OpenApiAny)i.Extensions["x-something"]).Node.Parent) - .Excluding(i => ((OpenApiAny)i.Extensions["x-contact"]).Node["name"].Parent) - .Excluding(i => ((OpenApiAny)i.Extensions["x-contact"]).Node["name"].Root) - .Excluding(i => ((OpenApiAny)i.Extensions["x-contact"]).Node["url"].Parent) - .Excluding(i => ((OpenApiAny)i.Extensions["x-contact"]).Node["url"].Root) - .Excluding(i => ((OpenApiAny)i.Extensions["x-contact"]).Node["email"].Parent) - .Excluding(i => ((OpenApiAny)i.Extensions["x-contact"]).Node["email"].Root) - .Excluding(i => ((OpenApiAny)i.Extensions["x-list"]).Node[0].Parent) - .Excluding(i => ((OpenApiAny)i.Extensions["x-list"]).Node[0].Root) - .Excluding(i => ((OpenApiAny)i.Extensions["x-list"]).Node[1].Parent) - .Excluding(i => ((OpenApiAny)i.Extensions["x-list"]).Node[1].Root)); + .Excluding(i => ((JsonNodeExtension)i.Contact.Extensions["x-twitter"]).Node.Parent) + .Excluding(i => ((JsonNodeExtension)i.License.Extensions["x-disclaimer"]).Node.Parent) + .Excluding(i => ((JsonNodeExtension)i.Extensions["x-something"]).Node.Parent) + .Excluding(i => ((JsonNodeExtension)i.Extensions["x-contact"]).Node["name"].Parent) + .Excluding(i => ((JsonNodeExtension)i.Extensions["x-contact"]).Node["name"].Root) + .Excluding(i => ((JsonNodeExtension)i.Extensions["x-contact"]).Node["url"].Parent) + .Excluding(i => ((JsonNodeExtension)i.Extensions["x-contact"]).Node["url"].Root) + .Excluding(i => ((JsonNodeExtension)i.Extensions["x-contact"]).Node["email"].Parent) + .Excluding(i => ((JsonNodeExtension)i.Extensions["x-contact"]).Node["email"].Root) + .Excluding(i => ((JsonNodeExtension)i.Extensions["x-list"]).Node[0].Parent) + .Excluding(i => ((JsonNodeExtension)i.Extensions["x-list"]).Node[0].Root) + .Excluding(i => ((JsonNodeExtension)i.Extensions["x-list"]).Node[1].Parent) + .Excluding(i => ((JsonNodeExtension)i.Extensions["x-list"]).Node[1].Root)); } [Fact] diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs index d9b4b1901..34cd2f9ca 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs @@ -5,7 +5,6 @@ using System.IO; using System.Text.Json.Nodes; using FluentAssertions; -using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Extensions; using SharpYaml.Serialization; @@ -65,12 +64,12 @@ public void ParseExampleStringFragmentShouldSucceed() }"; // Act - var openApiAny = OpenApiModelFactory.Parse(input, OpenApiSpecVersion.OpenApi3_0, new(), out var diagnostic, settings: SettingsFixture.ReaderSettings); + var jsonNodeExtension = OpenApiModelFactory.Parse(input, OpenApiSpecVersion.OpenApi3_0, new(), out var diagnostic, settings: SettingsFixture.ReaderSettings); // Assert Assert.Equivalent(new OpenApiDiagnostic(), diagnostic); - openApiAny.Should().BeEquivalentTo(new OpenApiAny( + jsonNodeExtension.Should().BeEquivalentTo(new JsonNodeExtension( new JsonObject { ["foo"] = "bar", @@ -88,12 +87,12 @@ public void ParseEnumFragmentShouldSucceed() ]"; // Act - var openApiAny = OpenApiModelFactory.Parse(input, OpenApiSpecVersion.OpenApi3_0, new(), out var diagnostic, settings: SettingsFixture.ReaderSettings); + var jsonNodeExtension = OpenApiModelFactory.Parse(input, OpenApiSpecVersion.OpenApi3_0, new(), out var diagnostic, settings: SettingsFixture.ReaderSettings); // Assert Assert.Equivalent(new OpenApiDiagnostic(), diagnostic); - openApiAny.Should().BeEquivalentTo(new OpenApiAny( + jsonNodeExtension.Should().BeEquivalentTo(new JsonNodeExtension( new JsonArray { "foo", @@ -213,8 +212,8 @@ public void ParseBasicSchemaWithExampleShouldSucceed() }, Example = new JsonObject { - ["name"] = new OpenApiAny("Puma").Node, - ["id"] = new OpenApiAny(1).Node + ["name"] = new JsonNodeExtension("Puma").Node, + ["id"] = new JsonNodeExtension(1).Node } }, options => options .IgnoringCyclicReferences() diff --git a/test/Microsoft.OpenApi.Tests/MicrosoftExtensions/OpenApiDeprecationExtensionTests.cs b/test/Microsoft.OpenApi.Tests/MicrosoftExtensions/OpenApiDeprecationExtensionTests.cs index f4364d032..ba721cc15 100644 --- a/test/Microsoft.OpenApi.Tests/MicrosoftExtensions/OpenApiDeprecationExtensionTests.cs +++ b/test/Microsoft.OpenApi.Tests/MicrosoftExtensions/OpenApiDeprecationExtensionTests.cs @@ -1,7 +1,6 @@ using System; using System.IO; using Microsoft.OpenApi.MicrosoftExtensions; -using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Writers; using Xunit; using System.Text.Json.Nodes; diff --git a/test/Microsoft.OpenApi.Tests/MicrosoftExtensions/OpenApiPagingExtensionsTests.cs b/test/Microsoft.OpenApi.Tests/MicrosoftExtensions/OpenApiPagingExtensionsTests.cs index 3d084908c..e341e5011 100644 --- a/test/Microsoft.OpenApi.Tests/MicrosoftExtensions/OpenApiPagingExtensionsTests.cs +++ b/test/Microsoft.OpenApi.Tests/MicrosoftExtensions/OpenApiPagingExtensionsTests.cs @@ -1,10 +1,10 @@ using System; using System.IO; using Microsoft.OpenApi.MicrosoftExtensions; -using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Writers; using Xunit; using System.Text.Json.Nodes; +using Microsoft.OpenApi.Extensions; namespace Microsoft.OpenApi.Tests.MicrosoftExtensions; @@ -77,9 +77,9 @@ public void ParsesPagingInfo() // Arrange var obj = new JsonObject { - ["nextLinkName"] = new OpenApiAny("@odata.nextLink").Node, - ["operationName"] = new OpenApiAny("more").Node, - ["itemName"] = new OpenApiAny("item").Node, + ["nextLinkName"] = new JsonNodeExtension("@odata.nextLink").Node, + ["operationName"] = new JsonNodeExtension("more").Node, + ["itemName"] = new JsonNodeExtension("item").Node, }; // Act diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiContactTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiContactTests.cs index 114956a11..5f729b884 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiContactTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiContactTests.cs @@ -1,11 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. -using System.Collections.Generic; using System.Threading.Tasks; -using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Extensions; -using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; using Xunit; @@ -23,7 +20,7 @@ public class OpenApiContactTests Email = "support@example.com", Extensions = new() { - {"x-internal-id", new OpenApiAny(42)} + {"x-internal-id", new JsonNodeExtension(42)} } }; diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs index 48310df15..bbeeaf10f 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs @@ -7,9 +7,7 @@ using System.IO; using System.Net.Http; using System.Threading.Tasks; -using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Extensions; -using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.Interfaces; using Microsoft.OpenApi.Models.References; @@ -973,12 +971,12 @@ public class OpenApiDocumentTests Type = JsonSchemaType.Integer, Extensions = new() { - ["my-extension"] = new OpenApiAny(4) + ["my-extension"] = new JsonNodeExtension(4) } }, Extensions = new() { - ["my-extension"] = new OpenApiAny(4), + ["my-extension"] = new JsonNodeExtension(4), } }, new OpenApiParameter @@ -992,12 +990,12 @@ public class OpenApiDocumentTests Type = JsonSchemaType.Integer, Extensions = new() { - ["my-extension"] = new OpenApiAny(4) + ["my-extension"] = new JsonNodeExtension(4) } }, Extensions = new() { - ["my-extension"] = new OpenApiAny(4), + ["my-extension"] = new JsonNodeExtension(4), } }, ], @@ -2079,7 +2077,7 @@ public async Task SerializeDocumentTagsWithMultipleExtensionsWorks() Name = "tag1", Extensions = new() { - ["x-tag1"] = new OpenApiAny("tag1") + ["x-tag1"] = new JsonNodeExtension("tag1") } }, new OpenApiTag @@ -2087,7 +2085,7 @@ public async Task SerializeDocumentTagsWithMultipleExtensionsWorks() Name = "tag2", Extensions = new() { - ["x-tag2"] = new OpenApiAny("tag2") + ["x-tag2"] = new JsonNodeExtension("tag2") } } } @@ -2108,7 +2106,7 @@ public void DeduplicatesTags() Name = "tag1", Extensions = new() { - ["x-tag1"] = new OpenApiAny("tag1") + ["x-tag1"] = new JsonNodeExtension("tag1") } }, new OpenApiTag @@ -2116,7 +2114,7 @@ public void DeduplicatesTags() Name = "tag2", Extensions = new() { - ["x-tag2"] = new OpenApiAny("tag2") + ["x-tag2"] = new JsonNodeExtension("tag2") } }, new OpenApiTag @@ -2124,7 +2122,7 @@ public void DeduplicatesTags() Name = "tag1", Extensions = new() { - ["x-tag1"] = new OpenApiAny("tag1") + ["x-tag1"] = new JsonNodeExtension("tag1") } } } diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiInfoTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiInfoTests.cs index c78c1d74f..3145ee146 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiInfoTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiInfoTests.cs @@ -3,9 +3,7 @@ using System.Collections.Generic; using System.Threading.Tasks; -using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Extensions; -using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; using Xunit; @@ -24,7 +22,7 @@ public class OpenApiInfoTests Version = "1.1.1", Extensions = new() { - {"x-updated", new OpenApiAny("metadata")} + {"x-updated", new JsonNodeExtension("metadata")} } }; diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiLicenseTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiLicenseTests.cs index acad2216a..114ac6945 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiLicenseTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiLicenseTests.cs @@ -1,11 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. -using System.Collections.Generic; using System.Threading.Tasks; -using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Extensions; -using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; using Xunit; @@ -25,7 +22,7 @@ public class OpenApiLicenseTests Url = new("http://www.apache.org/licenses/LICENSE-2.0.html"), Extensions = new() { - {"x-copyright", new OpenApiAny("Abc")} + {"x-copyright", new JsonNodeExtension("Abc")} } }; diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.cs index 03b406adf..0d1be7130 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.cs @@ -6,9 +6,8 @@ using System.IO; using System.Text.Json.Nodes; using System.Threading.Tasks; -using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Expressions; -using Microsoft.OpenApi.Interfaces; +using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.References; using Microsoft.OpenApi.Writers; @@ -128,7 +127,7 @@ public void LinkExtensionsSerializationWorks() { Extensions = new() { - { "x-display", new OpenApiAny("Abc") + { "x-display", new JsonNodeExtension("Abc") } } }; diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.cs index a9bb4ba78..78eb26f41 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.cs @@ -4,9 +4,7 @@ using System.Collections.Generic; using System.Globalization; using System.IO; -using System.Text.Json.Nodes; using System.Threading.Tasks; -using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.Interfaces; @@ -76,8 +74,8 @@ public class OpenApiParameterTests { Enum = [ - new OpenApiAny("value1").Node, - new OpenApiAny("value2").Node + new JsonNodeExtension("value1").Node, + new JsonNodeExtension("value2").Node ] } } @@ -97,8 +95,8 @@ public class OpenApiParameterTests { Enum = [ - new OpenApiAny("value1").Node, - new OpenApiAny("value2").Node + new JsonNodeExtension("value1").Node, + new JsonNodeExtension("value2").Node ] } } diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.cs index 4c579fb9e..64a111e9d 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.cs @@ -5,16 +5,13 @@ using System.Globalization; using System.IO; using System.Threading.Tasks; -using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Extensions; -using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.Interfaces; using Microsoft.OpenApi.Models.References; using Microsoft.OpenApi.Writers; using VerifyXunit; using Xunit; -using Xunit.Abstractions; namespace Microsoft.OpenApi.Tests.Models { @@ -38,7 +35,7 @@ public class OpenApiResponseTests Example = "Blabla", Extensions = new() { - ["myextension"] = new OpenApiAny("myextensionvalue"), + ["myextension"] = new JsonNodeExtension("myextensionvalue"), }, } }, @@ -77,7 +74,7 @@ public class OpenApiResponseTests Example = "Blabla", Extensions = new() { - ["myextension"] = new OpenApiAny("myextensionvalue"), + ["myextension"] = new JsonNodeExtension("myextensionvalue"), }, } }, diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs index 779a87e3e..82f1ac11b 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs @@ -8,9 +8,7 @@ using System.Text.Json.Nodes; using System.Threading.Tasks; using FluentAssertions; -using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Extensions; -using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.Interfaces; using Microsoft.OpenApi.Services; @@ -538,7 +536,7 @@ public void CloningSchemaExtensionsWorks() { Extensions = new() { - { "x-myextension", new OpenApiAny(42) } + { "x-myextension", new JsonNodeExtension(42) } } }; @@ -549,7 +547,7 @@ public void CloningSchemaExtensionsWorks() // Act && Assert schemaCopy.Extensions = new() { - { "x-myextension" , new OpenApiAny(40) } + { "x-myextension" , new JsonNodeExtension(40) } }; Assert.NotEqual(schema.Extensions, schemaCopy.Extensions); } diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiXmlTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiXmlTests.cs index 173bf6620..6848d2e3d 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiXmlTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiXmlTests.cs @@ -1,11 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. -using System.Collections.Generic; using System.Threading.Tasks; -using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Extensions; -using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; using Xunit; @@ -23,7 +20,7 @@ public class OpenApiXmlTests Attribute = true, Extensions = new() { - {"x-xml-extension", new OpenApiAny(7)} + {"x-xml-extension", new JsonNodeExtension(7)} } }; diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index 1e3c88ec0..080f648c7 100644 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -3,15 +3,6 @@ [assembly: System.Runtime.CompilerServices.InternalsVisibleTo(@"Microsoft.OpenApi.Readers.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100957cb48387b2a5f54f5ce39255f18f26d32a39990db27cf48737afc6bc62759ba996b8a2bfb675d4e39f3d06ecb55a178b1b4031dcb2a767e29977d88cce864a0d16bfc1b3bebb0edf9fe285f10fffc0a85f93d664fa05af07faa3aad2e545182dbf787e3fd32b56aca95df1a3c4e75dec164a3f1a4c653d971b01ffc39eb3c4")] [assembly: System.Runtime.CompilerServices.InternalsVisibleTo(@"Microsoft.OpenApi.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100957cb48387b2a5f54f5ce39255f18f26d32a39990db27cf48737afc6bc62759ba996b8a2bfb675d4e39f3d06ecb55a178b1b4031dcb2a767e29977d88cce864a0d16bfc1b3bebb0edf9fe285f10fffc0a85f93d664fa05af07faa3aad2e545182dbf787e3fd32b56aca95df1a3c4e75dec164a3f1a4c653d971b01ffc39eb3c4")] [assembly: System.Runtime.Versioning.TargetFramework(".NETCoreApp,Version=v8.0", FrameworkDisplayName=".NET 8.0")] -namespace Microsoft.OpenApi.Any -{ - public class OpenApiAny : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtension - { - public OpenApiAny(System.Text.Json.Nodes.JsonNode jsonNode) { } - public System.Text.Json.Nodes.JsonNode Node { get; } - public void Write(Microsoft.OpenApi.Writers.IOpenApiWriter writer, Microsoft.OpenApi.OpenApiSpecVersion specVersion) { } - } -} namespace Microsoft.OpenApi.Attributes { [System.AttributeUsage(System.AttributeTargets.Property | System.AttributeTargets.Field)] @@ -149,6 +140,12 @@ namespace Microsoft.OpenApi.Extensions where T : System.Attribute { } public static string GetDisplayName(this System.Enum enumValue) { } } + public class JsonNodeExtension : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtension + { + public JsonNodeExtension(System.Text.Json.Nodes.JsonNode jsonNode) { } + public System.Text.Json.Nodes.JsonNode Node { get; } + public void Write(Microsoft.OpenApi.Writers.IOpenApiWriter writer, Microsoft.OpenApi.OpenApiSpecVersion specVersion) { } + } public static class OpenApiElementExtensions { public static System.Collections.Generic.IEnumerable Validate(this Microsoft.OpenApi.Interfaces.IOpenApiElement element, Microsoft.OpenApi.Validations.ValidationRuleSet ruleSet) { } diff --git a/test/Microsoft.OpenApi.Tests/Services/OpenApiValidatorTests.cs b/test/Microsoft.OpenApi.Tests/Services/OpenApiValidatorTests.cs index 1de888cd3..13f34598b 100644 --- a/test/Microsoft.OpenApi.Tests/Services/OpenApiValidatorTests.cs +++ b/test/Microsoft.OpenApi.Tests/Services/OpenApiValidatorTests.cs @@ -6,7 +6,7 @@ using System.Net.Http; using System.Text.Json; using System.Text.Json.Nodes; -using Microsoft.OpenApi.Any; +using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Properties; @@ -103,8 +103,8 @@ public void ValidateCustomExtension() { var ruleset = ValidationRuleSet.GetDefaultRuleSet(); - ruleset.Add(typeof(OpenApiAny), - new ValidationRule("FooExtensionRule", + ruleset.Add(typeof(JsonNodeExtension), + new ValidationRule("FooExtensionRule", (context, item) => { if (item.Node["Bar"].ToString() == "hey") @@ -133,7 +133,7 @@ public void ValidateCustomExtension() var jsonNode = JsonNode.Parse(extensionNode); openApiDocument.Info.Extensions = new Dictionary { - { "x-foo", new OpenApiAny(jsonNode) } + { "x-foo", new JsonNodeExtension(jsonNode) } }; var validator = new OpenApiValidator(ruleset); @@ -150,8 +150,8 @@ public void ValidateCustomExtension() [Fact] public void RemoveRuleByName_Invalid() { - Assert.Throws(() => new ValidationRule(null, (vc, oaa) => { })); - Assert.Throws(() => new ValidationRule(string.Empty, (vc, oaa) => { })); + Assert.Throws(() => new ValidationRule(null, (vc, oaa) => { })); + Assert.Throws(() => new ValidationRule(string.Empty, (vc, oaa) => { })); } [Fact] diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiSchemaValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiSchemaValidationTests.cs index f0c772473..be2903023 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiSchemaValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiSchemaValidationTests.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using System.Linq; using System.Text.Json.Nodes; -using Microsoft.OpenApi.Any; +using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.Interfaces; using Microsoft.OpenApi.Properties; @@ -75,15 +75,15 @@ public void ValidateEnumShouldNotHaveDataTypeMismatchForSimpleSchema() { Enum = [ - new OpenApiAny("1").Node, - new OpenApiAny(new JsonObject() + new JsonNodeExtension("1").Node, + new JsonNodeExtension(new JsonObject() { ["x"] = 2, ["y"] = "20", ["z"] = "200" }).Node, - new OpenApiAny(new JsonArray() { 3 }).Node, - new OpenApiAny(new JsonObject() + new JsonNodeExtension(new JsonArray() { 3 }).Node, + new JsonNodeExtension(new JsonObject() { ["x"] = 4, ["y"] = 40, diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiTagValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiTagValidationTests.cs index 9824b17f6..400b83e13 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiTagValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiTagValidationTests.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; -using Microsoft.OpenApi.Any; +using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Properties; @@ -44,7 +44,7 @@ public void ValidateExtensionNameStartsWithXDashInTag() }; tag.Extensions = new Dictionary { - { "tagExt", new OpenApiAny("value") } + { "tagExt", new JsonNodeExtension("value") } }; // Act diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiJsonWriterTests.cs b/test/Microsoft.OpenApi.Tests/Writers/OpenApiJsonWriterTests.cs index fb149b5ec..d46e69ce6 100644 --- a/test/Microsoft.OpenApi.Tests/Writers/OpenApiJsonWriterTests.cs +++ b/test/Microsoft.OpenApi.Tests/Writers/OpenApiJsonWriterTests.cs @@ -10,10 +10,9 @@ using System.Text; using System.Text.Encodings.Web; using System.Text.Json; -using System.Text.Json.Nodes; using System.Text.Json.Serialization; using System.Threading.Tasks; -using Microsoft.OpenApi.Any; +using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Writers; using Xunit; @@ -320,9 +319,9 @@ public void OpenApiJsonWriterOutputsValidJsonValueWhenSchemaHasNanOrInfinityValu { Enum = [ - new OpenApiAny("NaN").Node, - new OpenApiAny("Infinity").Node, - new OpenApiAny("-Infinity").Node + new JsonNodeExtension("NaN").Node, + new JsonNodeExtension("Infinity").Node, + new JsonNodeExtension("-Infinity").Node ] }; From a493e9ca266521c27fb1d8aa8ad05cd622d432d8 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Wed, 23 Apr 2025 19:10:00 +0300 Subject: [PATCH 107/984] chore: update docs --- docs/upgrade-guide-2.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/upgrade-guide-2.md b/docs/upgrade-guide-2.md index f1fd6c23f..006486d81 100644 --- a/docs/upgrade-guide-2.md +++ b/docs/upgrade-guide-2.md @@ -203,7 +203,7 @@ var openApiObject = new OpenApiObject } }; var parameter = new OpenApiParameter(); -parameter.Extensions.Add("x-foo", new OpenApiAny(openApiObject)); +parameter.Extensions.Add("x-foo", new JsonNodeExtension(openApiObject)); ``` @@ -223,7 +223,7 @@ var openApiObject = new JsonObject } }; var parameter = new OpenApiParameter(); -parameter.Extensions.Add("x-foo", new OpenApiAny(openApiObject)); +parameter.Extensions.Add("x-foo", new JsonNodeExtension(openApiObject)); ``` From 7ad163a705e83c68d8ab182423ca34b81fa32522 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 23 Apr 2025 21:35:32 +0000 Subject: [PATCH 108/984] chore(deps): bump PublicApiGenerator from 11.4.5 to 11.4.6 Bumps [PublicApiGenerator](https://github.com/PublicApiGenerator/PublicApiGenerator) from 11.4.5 to 11.4.6. - [Release notes](https://github.com/PublicApiGenerator/PublicApiGenerator/releases) - [Commits](https://github.com/PublicApiGenerator/PublicApiGenerator/compare/11.4.5...11.4.6) --- updated-dependencies: - dependency-name: PublicApiGenerator dependency-version: 11.4.6 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index e0bdeb51d..b5406cd9f 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -19,7 +19,7 @@ - + From b63ab3bb63aeaaed5fb2efe014ac0b388cfb5208 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Mon, 28 Apr 2025 16:13:28 +0300 Subject: [PATCH 109/984] feat: implement tests for routing issues during serialization --- .../Models/OpenApiCallback.cs | 6 +- .../Models/OpenApiContact.cs | 6 +- .../Models/OpenApiEncoding.cs | 6 +- .../Models/OpenApiExample.cs | 6 +- .../Models/OpenApiExternalDocs.cs | 6 +- src/Microsoft.OpenApi/Models/OpenApiHeader.cs | 6 +- .../Models/OpenApiLicense.cs | 6 +- src/Microsoft.OpenApi/Models/OpenApiLink.cs | 6 +- .../Models/OpenApiMediaType.cs | 6 +- .../Models/OpenApiOAuthFlows.cs | 6 +- .../Models/OpenApiOperation.cs | 6 +- .../Models/OpenApiParameter.cs | 6 +- .../Models/OpenApiPathItem.cs | 7 +- .../Models/OpenApiRequestBody.cs | 6 +- .../Models/OpenApiResponse.cs | 6 +- src/Microsoft.OpenApi/Models/OpenApiSchema.cs | 6 +- .../Models/OpenApiSecurityScheme.cs | 6 +- src/Microsoft.OpenApi/Models/OpenApiServer.cs | 6 +- src/Microsoft.OpenApi/Models/OpenApiXml.cs | 6 +- .../Microsoft.OpenApi.Tests.csproj | 3 +- .../OpenApiCallbackSerializationTests.cs | 51 +++ .../OpenApiComponentsSerializationTests.cs | 121 +++++ .../Mocks/OpenApiDocumentMock.cs | 427 ++++++++++++++++++ .../OpenApiDocumentSerializationTests.cs | 91 ++++ .../OpenApiEncodingSerializationTests.cs | 51 +++ .../Mocks/OpenApiHeaderSerializationTests.cs | 66 +++ .../Mocks/OpenApiInfoSerializationTests.cs | 57 +++ .../OpenApiMediaTypeSerializationTests.cs | 67 +++ .../OpenApiOperationSerializationTests.cs | 101 +++++ .../OpenApiParameterSerializationTests.cs | 65 +++ .../OpenApiPathItemSerializationTests.cs | 67 +++ .../OpenApiRequestBodySerializationTests.cs | 51 +++ .../OpenApiResponseSerializationTests.cs | 67 +++ .../Mocks/OpenApiSchemaSerializationTests.cs | 50 ++ ...OpenApiSecuritySchemeSerializationTests.cs | 49 ++ .../Mocks/OpenApiTagsSerialization.cs | 50 ++ 36 files changed, 1490 insertions(+), 59 deletions(-) create mode 100644 test/Microsoft.OpenApi.Tests/Mocks/OpenApiCallbackSerializationTests.cs create mode 100644 test/Microsoft.OpenApi.Tests/Mocks/OpenApiComponentsSerializationTests.cs create mode 100644 test/Microsoft.OpenApi.Tests/Mocks/OpenApiDocumentMock.cs create mode 100644 test/Microsoft.OpenApi.Tests/Mocks/OpenApiDocumentSerializationTests.cs create mode 100644 test/Microsoft.OpenApi.Tests/Mocks/OpenApiEncodingSerializationTests.cs create mode 100644 test/Microsoft.OpenApi.Tests/Mocks/OpenApiHeaderSerializationTests.cs create mode 100644 test/Microsoft.OpenApi.Tests/Mocks/OpenApiInfoSerializationTests.cs create mode 100644 test/Microsoft.OpenApi.Tests/Mocks/OpenApiMediaTypeSerializationTests.cs create mode 100644 test/Microsoft.OpenApi.Tests/Mocks/OpenApiOperationSerializationTests.cs create mode 100644 test/Microsoft.OpenApi.Tests/Mocks/OpenApiParameterSerializationTests.cs create mode 100644 test/Microsoft.OpenApi.Tests/Mocks/OpenApiPathItemSerializationTests.cs create mode 100644 test/Microsoft.OpenApi.Tests/Mocks/OpenApiRequestBodySerializationTests.cs create mode 100644 test/Microsoft.OpenApi.Tests/Mocks/OpenApiResponseSerializationTests.cs create mode 100644 test/Microsoft.OpenApi.Tests/Mocks/OpenApiSchemaSerializationTests.cs create mode 100644 test/Microsoft.OpenApi.Tests/Mocks/OpenApiSecuritySchemeSerializationTests.cs create mode 100644 test/Microsoft.OpenApi.Tests/Mocks/OpenApiTagsSerialization.cs diff --git a/src/Microsoft.OpenApi/Models/OpenApiCallback.cs b/src/Microsoft.OpenApi/Models/OpenApiCallback.cs index 8bd90ed7f..ab84a7b3b 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiCallback.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiCallback.cs @@ -59,7 +59,7 @@ public void AddPathItem(RuntimeExpression expression, IOpenApiPathItem pathItem) /// /// /// - public void SerializeAsV31(IOpenApiWriter writer) + public virtual void SerializeAsV31(IOpenApiWriter writer) { SerializeInternal(writer, OpenApiSpecVersion.OpenApi3_1, (writer, element) => element.SerializeAsV31(writer)); } @@ -67,7 +67,7 @@ public void SerializeAsV31(IOpenApiWriter writer) /// /// Serialize to Open Api v3.0 /// - public void SerializeAsV3(IOpenApiWriter writer) + public virtual void SerializeAsV3(IOpenApiWriter writer) { SerializeInternal(writer, OpenApiSpecVersion.OpenApi3_0, (writer, element) => element.SerializeAsV3(writer)); } @@ -97,7 +97,7 @@ internal void SerializeInternal(IOpenApiWriter writer, OpenApiSpecVersion versio /// /// Serialize to Open Api v2.0 /// - public void SerializeAsV2(IOpenApiWriter writer) + public virtual void SerializeAsV2(IOpenApiWriter writer) { // Callback object does not exist in V2. } diff --git a/src/Microsoft.OpenApi/Models/OpenApiContact.cs b/src/Microsoft.OpenApi/Models/OpenApiContact.cs index b6ed82171..b3a567bd7 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiContact.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiContact.cs @@ -54,7 +54,7 @@ public OpenApiContact(OpenApiContact contact) /// Serialize to Open Api v3.1 /// /// - public void SerializeAsV31(IOpenApiWriter writer) + public virtual void SerializeAsV31(IOpenApiWriter writer) { WriteInternal(writer, OpenApiSpecVersion.OpenApi3_1); } @@ -62,7 +62,7 @@ public void SerializeAsV31(IOpenApiWriter writer) /// /// Serialize to Open Api v3.0 /// - public void SerializeAsV3(IOpenApiWriter writer) + public virtual void SerializeAsV3(IOpenApiWriter writer) { WriteInternal(writer, OpenApiSpecVersion.OpenApi3_0); } @@ -70,7 +70,7 @@ public void SerializeAsV3(IOpenApiWriter writer) /// /// Serialize to Open Api v2.0 /// - public void SerializeAsV2(IOpenApiWriter writer) + public virtual void SerializeAsV2(IOpenApiWriter writer) { WriteInternal(writer, OpenApiSpecVersion.OpenApi2_0); } diff --git a/src/Microsoft.OpenApi/Models/OpenApiEncoding.cs b/src/Microsoft.OpenApi/Models/OpenApiEncoding.cs index cc9340317..e08126586 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiEncoding.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiEncoding.cs @@ -76,7 +76,7 @@ public OpenApiEncoding(OpenApiEncoding encoding) /// Serialize to Open Api v3.1 /// /// - public void SerializeAsV31(IOpenApiWriter writer) + public virtual void SerializeAsV31(IOpenApiWriter writer) { SerializeInternal(writer, OpenApiSpecVersion.OpenApi3_1, (writer, element) => element.SerializeAsV31(writer)); } @@ -85,7 +85,7 @@ public void SerializeAsV31(IOpenApiWriter writer) /// Serialize to Open Api v3.0 /// /// - public void SerializeAsV3(IOpenApiWriter writer) + public virtual void SerializeAsV3(IOpenApiWriter writer) { SerializeInternal(writer, OpenApiSpecVersion.OpenApi3_0, (writer, element) => element.SerializeAsV3(writer)); } @@ -124,7 +124,7 @@ private void SerializeInternal(IOpenApiWriter writer, OpenApiSpecVersion version /// /// Serialize to Open Api v2.0. /// - public void SerializeAsV2(IOpenApiWriter writer) + public virtual void SerializeAsV2(IOpenApiWriter writer) { // nothing here } diff --git a/src/Microsoft.OpenApi/Models/OpenApiExample.cs b/src/Microsoft.OpenApi/Models/OpenApiExample.cs index 6ffb26f2e..09ba87d48 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiExample.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiExample.cs @@ -50,13 +50,13 @@ internal OpenApiExample(IOpenApiExample example) } /// - public void SerializeAsV31(IOpenApiWriter writer) + public virtual void SerializeAsV31(IOpenApiWriter writer) { SerializeInternal(writer, OpenApiSpecVersion.OpenApi3_1); } /// - public void SerializeAsV3(IOpenApiWriter writer) + public virtual void SerializeAsV3(IOpenApiWriter writer) { SerializeInternal(writer, OpenApiSpecVersion.OpenApi3_0); } @@ -86,7 +86,7 @@ private void SerializeInternal(IOpenApiWriter writer, OpenApiSpecVersion version } /// - public void SerializeAsV2(IOpenApiWriter writer) + public virtual void SerializeAsV2(IOpenApiWriter writer) { SerializeInternal(writer, OpenApiSpecVersion.OpenApi2_0); } diff --git a/src/Microsoft.OpenApi/Models/OpenApiExternalDocs.cs b/src/Microsoft.OpenApi/Models/OpenApiExternalDocs.cs index 381ee53bb..9532eb54a 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiExternalDocs.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiExternalDocs.cs @@ -46,7 +46,7 @@ public OpenApiExternalDocs(OpenApiExternalDocs externalDocs) /// /// Serialize to Open Api v3.1. /// - public void SerializeAsV31(IOpenApiWriter writer) + public virtual void SerializeAsV31(IOpenApiWriter writer) { WriteInternal(writer, OpenApiSpecVersion.OpenApi3_1); } @@ -54,7 +54,7 @@ public void SerializeAsV31(IOpenApiWriter writer) /// /// Serialize to Open Api v3.0. /// - public void SerializeAsV3(IOpenApiWriter writer) + public virtual void SerializeAsV3(IOpenApiWriter writer) { WriteInternal(writer, OpenApiSpecVersion.OpenApi3_0); } @@ -62,7 +62,7 @@ public void SerializeAsV3(IOpenApiWriter writer) /// /// Serialize to Open Api v2.0. /// - public void SerializeAsV2(IOpenApiWriter writer) + public virtual void SerializeAsV2(IOpenApiWriter writer) { WriteInternal(writer, OpenApiSpecVersion.OpenApi2_0); } diff --git a/src/Microsoft.OpenApi/Models/OpenApiHeader.cs b/src/Microsoft.OpenApi/Models/OpenApiHeader.cs index 62bb09b89..619233257 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiHeader.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiHeader.cs @@ -83,7 +83,7 @@ internal OpenApiHeader(IOpenApiHeader header) /// /// Serialize to Open Api v3.1 /// - public void SerializeAsV31(IOpenApiWriter writer) + public virtual void SerializeAsV31(IOpenApiWriter writer) { SerializeInternal(writer, OpenApiSpecVersion.OpenApi3_0, (writer, element) => element.SerializeAsV31(writer)); } @@ -91,7 +91,7 @@ public void SerializeAsV31(IOpenApiWriter writer) /// /// Serialize to Open Api v3.0 /// - public void SerializeAsV3(IOpenApiWriter writer) + public virtual void SerializeAsV3(IOpenApiWriter writer) { SerializeInternal(writer, OpenApiSpecVersion.OpenApi3_0, (writer, element) => element.SerializeAsV3(writer)); } @@ -145,7 +145,7 @@ internal void SerializeInternal(IOpenApiWriter writer, OpenApiSpecVersion versio /// /// Serialize to OpenAPI V2 document without using reference. /// - public void SerializeAsV2(IOpenApiWriter writer) + public virtual void SerializeAsV2(IOpenApiWriter writer) { Utils.CheckArgumentNull(writer); diff --git a/src/Microsoft.OpenApi/Models/OpenApiLicense.cs b/src/Microsoft.OpenApi/Models/OpenApiLicense.cs index c3c36812c..18530f214 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiLicense.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiLicense.cs @@ -52,7 +52,7 @@ public OpenApiLicense(OpenApiLicense license) /// /// Serialize to Open Api v3.1 /// - public void SerializeAsV31(IOpenApiWriter writer) + public virtual void SerializeAsV31(IOpenApiWriter writer) { WriteInternal(writer, OpenApiSpecVersion.OpenApi3_1); writer.WriteProperty(OpenApiConstants.Identifier, Identifier); @@ -62,7 +62,7 @@ public void SerializeAsV31(IOpenApiWriter writer) /// /// Serialize to Open Api v3.0 /// - public void SerializeAsV3(IOpenApiWriter writer) + public virtual void SerializeAsV3(IOpenApiWriter writer) { WriteInternal(writer, OpenApiSpecVersion.OpenApi3_0); writer.WriteEndObject(); @@ -71,7 +71,7 @@ public void SerializeAsV3(IOpenApiWriter writer) /// /// Serialize to Open Api v2.0 /// - public void SerializeAsV2(IOpenApiWriter writer) + public virtual void SerializeAsV2(IOpenApiWriter writer) { WriteInternal(writer, OpenApiSpecVersion.OpenApi2_0); writer.WriteEndObject(); diff --git a/src/Microsoft.OpenApi/Models/OpenApiLink.cs b/src/Microsoft.OpenApi/Models/OpenApiLink.cs index ea9202186..4e343c842 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiLink.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiLink.cs @@ -56,13 +56,13 @@ internal OpenApiLink(IOpenApiLink link) } /// - public void SerializeAsV31(IOpenApiWriter writer) + public virtual void SerializeAsV31(IOpenApiWriter writer) { SerializeInternal(writer, (writer, element) => element.SerializeAsV31(writer)); } /// - public void SerializeAsV3(IOpenApiWriter writer) + public virtual void SerializeAsV3(IOpenApiWriter writer) { SerializeInternal(writer, (writer, element) => element.SerializeAsV3(writer)); } @@ -98,7 +98,7 @@ internal void SerializeInternal(IOpenApiWriter writer, Action - public void SerializeAsV2(IOpenApiWriter writer) + public virtual void SerializeAsV2(IOpenApiWriter writer) { // Link object does not exist in V2. } diff --git a/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs b/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs index a16f8d11f..711b0c71e 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs @@ -67,7 +67,7 @@ public OpenApiMediaType(OpenApiMediaType? mediaType) /// /// Serialize to Open Api v3.1. /// - public void SerializeAsV31(IOpenApiWriter writer) + public virtual void SerializeAsV31(IOpenApiWriter writer) { SerializeInternal(writer, OpenApiSpecVersion.OpenApi3_1, (w, element) => element.SerializeAsV31(w)); } @@ -75,7 +75,7 @@ public void SerializeAsV31(IOpenApiWriter writer) /// /// Serialize to Open Api v3.0. /// - public void SerializeAsV3(IOpenApiWriter writer) + public virtual void SerializeAsV3(IOpenApiWriter writer) { SerializeInternal(writer, OpenApiSpecVersion.OpenApi3_0, (w, element) => element.SerializeAsV3(w)); } @@ -114,7 +114,7 @@ private void SerializeInternal(IOpenApiWriter writer, OpenApiSpecVersion version /// /// Serialize to Open Api v2.0. /// - public void SerializeAsV2(IOpenApiWriter writer) + public virtual void SerializeAsV2(IOpenApiWriter writer) { // Media type does not exist in V2. } diff --git a/src/Microsoft.OpenApi/Models/OpenApiOAuthFlows.cs b/src/Microsoft.OpenApi/Models/OpenApiOAuthFlows.cs index b46b41da1..59efdb5fe 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiOAuthFlows.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiOAuthFlows.cs @@ -59,7 +59,7 @@ public OpenApiOAuthFlows(OpenApiOAuthFlows oAuthFlows) /// /// Serialize to Open Api v3.1 /// - public void SerializeAsV31(IOpenApiWriter writer) + public virtual void SerializeAsV31(IOpenApiWriter writer) { SerializeInternal(writer, OpenApiSpecVersion.OpenApi3_1, (writer, element) => element.SerializeAsV31(writer)); } @@ -67,7 +67,7 @@ public void SerializeAsV31(IOpenApiWriter writer) /// /// Serialize to Open Api v3.0 /// - public void SerializeAsV3(IOpenApiWriter writer) + public virtual void SerializeAsV3(IOpenApiWriter writer) { SerializeInternal(writer, OpenApiSpecVersion.OpenApi3_0, (writer, element) => element.SerializeAsV3(writer)); } @@ -109,7 +109,7 @@ private void SerializeInternal(IOpenApiWriter writer, OpenApiSpecVersion version /// /// Serialize to Open Api v2.0 /// - public void SerializeAsV2(IOpenApiWriter writer) + public virtual void SerializeAsV2(IOpenApiWriter writer) { // OAuthFlows object does not exist in V2. } diff --git a/src/Microsoft.OpenApi/Models/OpenApiOperation.cs b/src/Microsoft.OpenApi/Models/OpenApiOperation.cs index 3024f230a..b9160d36a 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiOperation.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiOperation.cs @@ -158,7 +158,7 @@ public OpenApiOperation(OpenApiOperation operation) /// /// Serialize to Open Api v3.1. /// - public void SerializeAsV31(IOpenApiWriter writer) + public virtual void SerializeAsV31(IOpenApiWriter writer) { SerializeInternal(writer, OpenApiSpecVersion.OpenApi3_1, (writer, element) => element.SerializeAsV31(writer)); } @@ -166,7 +166,7 @@ public void SerializeAsV31(IOpenApiWriter writer) /// /// Serialize to Open Api v3.0. /// - public void SerializeAsV3(IOpenApiWriter writer) + public virtual void SerializeAsV3(IOpenApiWriter writer) { SerializeInternal(writer, OpenApiSpecVersion.OpenApi3_0, (writer, element) => element.SerializeAsV3(writer)); } @@ -228,7 +228,7 @@ private void SerializeInternal(IOpenApiWriter writer, OpenApiSpecVersion version /// /// Serialize to Open Api v2.0. /// - public void SerializeAsV2(IOpenApiWriter writer) + public virtual void SerializeAsV2(IOpenApiWriter writer) { Utils.CheckArgumentNull(writer); diff --git a/src/Microsoft.OpenApi/Models/OpenApiParameter.cs b/src/Microsoft.OpenApi/Models/OpenApiParameter.cs index a990ddcbb..d49ccda49 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiParameter.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiParameter.cs @@ -100,13 +100,13 @@ internal OpenApiParameter(IOpenApiParameter parameter) } /// - public void SerializeAsV31(IOpenApiWriter writer) + public virtual void SerializeAsV31(IOpenApiWriter writer) { SerializeInternal(writer, OpenApiSpecVersion.OpenApi3_1, (writer, element) => element.SerializeAsV31(writer)); } /// - public void SerializeAsV3(IOpenApiWriter writer) + public virtual void SerializeAsV3(IOpenApiWriter writer) { SerializeInternal(writer, OpenApiSpecVersion.OpenApi3_0, (writer, element) => element.SerializeAsV3(writer)); } @@ -248,7 +248,7 @@ internal virtual void WriteRequestBodySchemaForV2(IOpenApiWriter writer, Diction } /// - public void SerializeAsV2(IOpenApiWriter writer) + public virtual void SerializeAsV2(IOpenApiWriter writer) { Utils.CheckArgumentNull(writer); diff --git a/src/Microsoft.OpenApi/Models/OpenApiPathItem.cs b/src/Microsoft.OpenApi/Models/OpenApiPathItem.cs index a001b922c..a6b86ec69 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiPathItem.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiPathItem.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.Net.Http; -using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models.Interfaces; using Microsoft.OpenApi.Writers; @@ -67,7 +66,7 @@ internal OpenApiPathItem(IOpenApiPathItem pathItem) /// /// Serialize to Open Api v3.1 /// - public void SerializeAsV31(IOpenApiWriter writer) + public virtual void SerializeAsV31(IOpenApiWriter writer) { SerializeInternal(writer, OpenApiSpecVersion.OpenApi3_1, (writer, element) => element.SerializeAsV31(writer)); } @@ -75,7 +74,7 @@ public void SerializeAsV31(IOpenApiWriter writer) /// /// Serialize to Open Api v3.0 /// - public void SerializeAsV3(IOpenApiWriter writer) + public virtual void SerializeAsV3(IOpenApiWriter writer) { SerializeInternal(writer, OpenApiSpecVersion.OpenApi3_0, (writer, element) => element.SerializeAsV3(writer)); } @@ -84,7 +83,7 @@ public void SerializeAsV3(IOpenApiWriter writer) /// Serialize inline PathItem in OpenAPI V2 /// /// - public void SerializeAsV2(IOpenApiWriter writer) + public virtual void SerializeAsV2(IOpenApiWriter writer) { Utils.CheckArgumentNull(writer); diff --git a/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs b/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs index 302cfc5ae..afee60db9 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs @@ -50,7 +50,7 @@ internal OpenApiRequestBody(IOpenApiRequestBody requestBody) /// /// Serialize to Open Api v3.1 /// - public void SerializeAsV31(IOpenApiWriter writer) + public virtual void SerializeAsV31(IOpenApiWriter writer) { SerializeInternal(writer, OpenApiSpecVersion.OpenApi3_1, (writer, element) => element.SerializeAsV31(writer)); } @@ -58,7 +58,7 @@ public void SerializeAsV31(IOpenApiWriter writer) /// /// Serialize to Open Api v3.0 /// - public void SerializeAsV3(IOpenApiWriter writer) + public virtual void SerializeAsV3(IOpenApiWriter writer) { SerializeInternal(writer, OpenApiSpecVersion.OpenApi3_0, (writer, element) => element.SerializeAsV3(writer)); } @@ -88,7 +88,7 @@ internal void SerializeInternal(IOpenApiWriter writer, OpenApiSpecVersion versio /// /// Serialize to Open Api v2.0 /// - public void SerializeAsV2(IOpenApiWriter writer) + public virtual void SerializeAsV2(IOpenApiWriter writer) { // RequestBody object does not exist in V2. } diff --git a/src/Microsoft.OpenApi/Models/OpenApiResponse.cs b/src/Microsoft.OpenApi/Models/OpenApiResponse.cs index 13ab81152..d52b15781 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiResponse.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiResponse.cs @@ -51,7 +51,7 @@ internal OpenApiResponse(IOpenApiResponse response) /// /// Serialize to Open Api v3.1 /// - public void SerializeAsV31(IOpenApiWriter writer) + public virtual void SerializeAsV31(IOpenApiWriter writer) { SerializeInternal(writer, OpenApiSpecVersion.OpenApi3_1, (writer, element) => element.SerializeAsV31(writer)); } @@ -59,7 +59,7 @@ public void SerializeAsV31(IOpenApiWriter writer) /// /// Serialize to Open Api v3.0. /// - public void SerializeAsV3(IOpenApiWriter writer) + public virtual void SerializeAsV3(IOpenApiWriter writer) { SerializeInternal(writer, OpenApiSpecVersion.OpenApi3_0, (writer, element) => element.SerializeAsV3(writer)); } @@ -92,7 +92,7 @@ private void SerializeInternal(IOpenApiWriter writer, OpenApiSpecVersion version /// /// Serialize to OpenAPI V2 document without using reference. /// - public void SerializeAsV2(IOpenApiWriter writer) + public virtual void SerializeAsV2(IOpenApiWriter writer) { Utils.CheckArgumentNull(writer); diff --git a/src/Microsoft.OpenApi/Models/OpenApiSchema.cs b/src/Microsoft.OpenApi/Models/OpenApiSchema.cs index 94d0d9299..2cadb1122 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiSchema.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiSchema.cs @@ -323,13 +323,13 @@ internal OpenApiSchema(IOpenApiSchema schema) } /// - public void SerializeAsV31(IOpenApiWriter writer) + public virtual void SerializeAsV31(IOpenApiWriter writer) { SerializeInternal(writer, OpenApiSpecVersion.OpenApi3_1, (writer, element) => element.SerializeAsV31(writer)); } /// - public void SerializeAsV3(IOpenApiWriter writer) + public virtual void SerializeAsV3(IOpenApiWriter writer) { SerializeInternal(writer, OpenApiSpecVersion.OpenApi3_0, (writer, element) => element.SerializeAsV3(writer)); } @@ -514,7 +514,7 @@ private void SerializeInternal(IOpenApiWriter writer, OpenApiSpecVersion version } /// - public void SerializeAsV2(IOpenApiWriter writer) + public virtual void SerializeAsV2(IOpenApiWriter writer) { SerializeAsV2(writer: writer, parentRequiredProperties: new HashSet(), propertyName: null); } diff --git a/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs b/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs index 992fe7986..83042912d 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs @@ -67,7 +67,7 @@ internal OpenApiSecurityScheme(IOpenApiSecurityScheme securityScheme) /// /// Serialize to Open Api v3.1 /// - public void SerializeAsV31(IOpenApiWriter writer) + public virtual void SerializeAsV31(IOpenApiWriter writer) { SerializeInternal(writer, OpenApiSpecVersion.OpenApi3_1, (writer, element) => element.SerializeAsV31(writer)); } @@ -75,7 +75,7 @@ public void SerializeAsV31(IOpenApiWriter writer) /// /// Serialize to Open Api v3.0 /// - public void SerializeAsV3(IOpenApiWriter writer) + public virtual void SerializeAsV3(IOpenApiWriter writer) { SerializeInternal(writer, OpenApiSpecVersion.OpenApi3_0, (writer, element) => element.SerializeAsV3(writer)); } @@ -130,7 +130,7 @@ private void SerializeInternal(IOpenApiWriter writer, OpenApiSpecVersion version /// /// Serialize to Open Api v2.0 /// - public void SerializeAsV2(IOpenApiWriter writer) + public virtual void SerializeAsV2(IOpenApiWriter writer) { Utils.CheckArgumentNull(writer); diff --git a/src/Microsoft.OpenApi/Models/OpenApiServer.cs b/src/Microsoft.OpenApi/Models/OpenApiServer.cs index 9c5b3cfca..af75c9c44 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiServer.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiServer.cs @@ -54,7 +54,7 @@ public OpenApiServer(OpenApiServer server) /// /// Serialize to Open Api v3.1 /// - public void SerializeAsV31(IOpenApiWriter writer) + public virtual void SerializeAsV31(IOpenApiWriter writer) { SerializeInternal(writer, OpenApiSpecVersion.OpenApi3_1, (writer, element) => element.SerializeAsV31(writer)); } @@ -62,7 +62,7 @@ public void SerializeAsV31(IOpenApiWriter writer) /// /// Serialize to Open Api v3.0 /// - public void SerializeAsV3(IOpenApiWriter writer) + public virtual void SerializeAsV3(IOpenApiWriter writer) { SerializeInternal(writer, OpenApiSpecVersion.OpenApi3_0, (writer, element) => element.SerializeAsV3(writer)); } @@ -95,7 +95,7 @@ private void SerializeInternal(IOpenApiWriter writer, OpenApiSpecVersion version /// /// Serialize to Open Api v2.0 /// - public void SerializeAsV2(IOpenApiWriter writer) + public virtual void SerializeAsV2(IOpenApiWriter writer) { // Server object does not exist in V2. } diff --git a/src/Microsoft.OpenApi/Models/OpenApiXml.cs b/src/Microsoft.OpenApi/Models/OpenApiXml.cs index ae8a94a46..552241d17 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiXml.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiXml.cs @@ -66,7 +66,7 @@ public OpenApiXml(OpenApiXml xml) /// /// Serialize to Open Api v3.0 /// - public void SerializeAsV31(IOpenApiWriter writer) + public virtual void SerializeAsV31(IOpenApiWriter writer) { Write(writer, OpenApiSpecVersion.OpenApi3_1); } @@ -74,7 +74,7 @@ public void SerializeAsV31(IOpenApiWriter writer) /// /// Serialize to Open Api v3.0 /// - public void SerializeAsV3(IOpenApiWriter writer) + public virtual void SerializeAsV3(IOpenApiWriter writer) { Write(writer, OpenApiSpecVersion.OpenApi3_0); } @@ -82,7 +82,7 @@ public void SerializeAsV3(IOpenApiWriter writer) /// /// Serialize to Open Api v2.0 /// - public void SerializeAsV2(IOpenApiWriter writer) + public virtual void SerializeAsV2(IOpenApiWriter writer) { Write(writer, OpenApiSpecVersion.OpenApi2_0); } diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index cf5736be0..e95792d72 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -1,4 +1,4 @@ - + net8.0 false @@ -26,6 +26,7 @@ + diff --git a/test/Microsoft.OpenApi.Tests/Mocks/OpenApiCallbackSerializationTests.cs b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiCallbackSerializationTests.cs new file mode 100644 index 000000000..70d61f7d0 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiCallbackSerializationTests.cs @@ -0,0 +1,51 @@ +using System.IO; +using System.Net.Http; +using Microsoft.OpenApi.Expressions; +using Microsoft.OpenApi.Models; +using Microsoft.OpenApi.Writers; +using Moq; +using Xunit; + +namespace Microsoft.OpenApi.Tests.Mocks +{ + public class OpenApiCallbackSerializationTests + { + private static readonly OpenApiCallback _callback = (OpenApiCallback)OpenApiDocumentMock.CreateCompleteOpenApiDocument().Paths["/pets"].Operations[HttpMethod.Get].Callbacks["onData"]; + private static readonly Mock _pathItemMock = new() { CallBase = true }; + + public OpenApiCallbackSerializationTests() + { + _callback.PathItems[RuntimeExpression.Build("{$request.body#/callbackUrl}")] = _pathItemMock.Object; + } + + [Fact] + public void SerializeAsV31_DoesNotCallV3OrV2Serialization() + { + // Arrange + using var stringWriter = new StringWriter(); + var writer = new OpenApiJsonWriter(stringWriter); + + // Act + _callback.SerializeAsV31(writer); + + // Assert - fail if V2 or V3 methods are called + _pathItemMock.Verify(c => c.SerializeAsV3(It.IsAny()), Times.Never, "V3 method should not be called"); + _pathItemMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + } + + [Fact] + public void SerializeAsV3_DoesNotCallV31OrV2Serialization() + { + // Arrange + using var stringWriter = new StringWriter(); + var writer = new OpenApiJsonWriter(stringWriter); + + // Act + _callback.SerializeAsV3(writer); + + // Assert - fail if V2 or V3 methods are called + _pathItemMock.Verify(c => c.SerializeAsV31(It.IsAny()), Times.Never, "V31 method should not be called"); + _pathItemMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + } + } +} diff --git a/test/Microsoft.OpenApi.Tests/Mocks/OpenApiComponentsSerializationTests.cs b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiComponentsSerializationTests.cs new file mode 100644 index 000000000..785739028 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiComponentsSerializationTests.cs @@ -0,0 +1,121 @@ +using System.IO; +using Microsoft.OpenApi.Models; +using Microsoft.OpenApi.Writers; +using Moq; +using Xunit; + +namespace Microsoft.OpenApi.Tests.Mocks +{ + public class OpenApiComponentsSerializationTests + { + private static readonly OpenApiComponents _components = OpenApiDocumentMock.CreateCompleteOpenApiDocument().Components; + private static readonly Mock _schemaMock = new() { CallBase = true }; + private static readonly Mock _requestBodyMock = new() { CallBase = true }; + private static readonly Mock _responseMock = new() { CallBase = true }; + private static readonly Mock _parameterMock = new() { CallBase = true }; + private static readonly Mock _headerMock = new() { CallBase = true }; + private static readonly Mock _securitySchemeMock = new() { CallBase = true }; + private static readonly Mock _linkMock = new() { CallBase = true }; + private static readonly Mock _callbackMock = new() { CallBase = true }; + private static readonly Mock _exampleMock = new() { CallBase = true }; + private static readonly Mock _pathItemMock = new() { CallBase = true }; + + public OpenApiComponentsSerializationTests() + { + _components.Schemas["pet"] = _schemaMock.Object; + _components.RequestBodies["pet"] = _requestBodyMock.Object; + _components.Responses["200"] = _responseMock.Object; + _components.Parameters["limit"] = _parameterMock.Object; + _components.Headers["x-rate-limit"] = _headerMock.Object; + _components.SecuritySchemes["api_key"] = _securitySchemeMock.Object; + _components.Links["UserRepositories"] = _linkMock.Object; + _components.Callbacks["onData"] = _callbackMock.Object; + _components.Examples["cat"] = _exampleMock.Object; + _components.PathItems["/pets"] = _pathItemMock.Object; + } + + [Fact] + public void SerializeAsV31_DoesNotCallV3OrV2Serialization() + { + // Arrange + using var stringWriter = new StringWriter(); + var writer = new OpenApiJsonWriter(stringWriter); + + // Act + _components.SerializeAsV31(writer); + + // Assert - fail if V2 or V3 methods are called + _schemaMock.Verify(c => c.SerializeAsV3(It.IsAny()), Times.Never, "V3 method should not be called"); + _schemaMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _requestBodyMock.Verify(c => c.SerializeAsV3(It.IsAny()), Times.Never, "V3 method should not be called"); + _requestBodyMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _responseMock.Verify(c => c.SerializeAsV3(It.IsAny()), Times.Never, "V3 method should not be called"); + _responseMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _parameterMock.Verify(c => c.SerializeAsV3(It.IsAny()), Times.Never, "V3 method should not be called"); + _parameterMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _headerMock.Verify(c => c.SerializeAsV3(It.IsAny()), Times.Never, "V3 method should not be called"); + _headerMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _securitySchemeMock.Verify(c => c.SerializeAsV3(It.IsAny()), Times.Never, "V3 method should not be called"); + _securitySchemeMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _linkMock.Verify(c => c.SerializeAsV3(It.IsAny()), Times.Never, "V3 method should not be called"); + _linkMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _callbackMock.Verify(c => c.SerializeAsV3(It.IsAny()), Times.Never, "V3 method should not be called"); + _callbackMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _exampleMock.Verify(c => c.SerializeAsV3(It.IsAny()), Times.Never, "V3 method should not be called"); + _exampleMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _pathItemMock.Verify(c => c.SerializeAsV3(It.IsAny()), Times.Never, "V3 method should not be called"); + _pathItemMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + } + + [Fact] + public void SerializeAsV3_DoesNotCallV31OrV2Serialization() + { + // Arrange + using var stringWriter = new StringWriter(); + var writer = new OpenApiJsonWriter(stringWriter); + + // Act + _components.SerializeAsV3(writer); + + // Assert - fail if V2 or V3 methods are called + _schemaMock.Verify(c => c.SerializeAsV31(It.IsAny()), Times.Never, "V31 method should not be called"); + _schemaMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _requestBodyMock.Verify(c => c.SerializeAsV31(It.IsAny()), Times.Never, "V31 method should not be called"); + _requestBodyMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _responseMock.Verify(c => c.SerializeAsV31(It.IsAny()), Times.Never, "V31 method should not be called"); + _responseMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _parameterMock.Verify(c => c.SerializeAsV31(It.IsAny()), Times.Never, "V31 method should not be called"); + _parameterMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _headerMock.Verify(c => c.SerializeAsV31(It.IsAny()), Times.Never, "V31 method should not be called"); + _headerMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _securitySchemeMock.Verify(c => c.SerializeAsV31(It.IsAny()), Times.Never, "V31 method should not be called"); + _securitySchemeMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _linkMock.Verify(c => c.SerializeAsV31(It.IsAny()), Times.Never, "V31 method should not be called"); + _linkMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _callbackMock.Verify(c => c.SerializeAsV31(It.IsAny()), Times.Never, "V31 method should not be called"); + _callbackMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _exampleMock.Verify(c => c.SerializeAsV31(It.IsAny()), Times.Never, "V31 method should not be called"); + _exampleMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _pathItemMock.Verify(c => c.SerializeAsV31(It.IsAny()), Times.Never, "V31 method should not be called"); + _pathItemMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + } + } +} diff --git a/test/Microsoft.OpenApi.Tests/Mocks/OpenApiDocumentMock.cs b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiDocumentMock.cs new file mode 100644 index 000000000..961699b3a --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiDocumentMock.cs @@ -0,0 +1,427 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Text.Json.Nodes; +using Microsoft.OpenApi.Expressions; +using Microsoft.OpenApi.Models; +using Microsoft.OpenApi.Models.Interfaces; +using Microsoft.OpenApi.Models.References; + +namespace Microsoft.OpenApi.Tests.Mocks +{ + public static class OpenApiDocumentMock + { + public static OpenApiDocument CreateCompleteOpenApiDocument() + { + var doc = new OpenApiDocument + { + Info = new OpenApiInfo + { + Title = "Sample API", + Version = "1.0.0" + }, + Servers = new List + { + new() + { + Url = "https://api.example.com", + Description = "Production server" + } + }, + Webhooks = new Dictionary + { + ["pets"] = new OpenApiPathItem + { + Operations = new() + { + [HttpMethod.Get] = new OpenApiOperation + { + Description = "Returns all pets from the system that the user has access to", + OperationId = "findPets", + Responses = new OpenApiResponses + { + ["200"] = new OpenApiResponse + { + Description = "pet response", + Content = new() + { + ["application/json"] = new OpenApiMediaType + { + Schema = new OpenApiSchema() + { + Type = JsonSchemaType.Array, + } + } + } + } + } + } + } + } + }, + Paths = new OpenApiPaths + { + ["/pets"] = new OpenApiPathItem + { + Servers = + [ + new() + { + Url = "https://api.example.com", + Description = "Production server" + } + ], + Parameters = + [ + new OpenApiParameter + { + Name = "limit", + In = ParameterLocation.Query, + Description = "How many items to return at one time (max 100)", + Required = false, + Schema = new OpenApiSchema + { + Type = JsonSchemaType.Integer, + Format = "int32" + }, + Examples = new Dictionary + { + ["cat"] = new OpenApiExample + { + Summary = "An example cat", + Value = JsonValue.Create("Fluffy") + } + }, + } + ], + Operations = new Dictionary + { + [HttpMethod.Get] = new OpenApiOperation + { + Summary = "List all pets", + Callbacks = new Dictionary + { + ["onData"] = new OpenApiCallback + { + PathItems = new Dictionary + { + [RuntimeExpression.Build("{$request.body#/callbackUrl}")] = new OpenApiPathItem + { + Operations = new Dictionary + { + [HttpMethod.Post] = new OpenApiOperation + { + Responses = new OpenApiResponses + { + ["200"] = new OpenApiResponse { Description = "ok" } + } + } + } + } + } + } + }, + Parameters = + [ + new OpenApiParameter + { + Name = "limit", + In = ParameterLocation.Query, + Description = "How many items to return at one time (max 100)", + Required = false, + Schema = new OpenApiSchema + { + Type = JsonSchemaType.Integer, + Format = "int32" + } + } + ], + RequestBody = new OpenApiRequestBody + { + Content = new Dictionary + { + ["application/json"] = new OpenApiMediaType + { + Schema = new OpenApiSchemaReference("Pet") + }, + ["application/xml"] = new OpenApiMediaType + { + Schema = new OpenApiSchema + { + Type = JsonSchemaType.String, + Xml = new OpenApiXml + { + Name = "name1", + Namespace = new Uri("http://example.com/schema/namespaceSample"), + } + }, + } + } + }, + Responses = new OpenApiResponses + { + ["200"] = new OpenApiResponse + { + Description = "A list of pets.", + Headers = new Dictionary + { + ["x-rate-limit"] = new OpenApiHeader + { + Description = "The number of allowed requests in the current period", + Schema = new OpenApiSchema + { + Type = JsonSchemaType.Integer + }, + Examples = new Dictionary + { + ["cat"] = new OpenApiExample + { + Summary = "An example cat", + Value = JsonValue.Create("Fluffy") + } + } + } + }, + Links = new Dictionary + { + ["UserRepositories"] = new OpenApiLink + { + OperationId = "getRepositoriesByUsername", + Parameters = new Dictionary + { + ["username"] = new RuntimeExpressionAnyWrapper + { + Expression = RuntimeExpression.Build("$request.path.id") + } + } + } + }, + Content = new Dictionary + { + ["application/json"] = new OpenApiMediaType + { + Encoding = new Dictionary + { + ["x-rate-limit"] = new OpenApiEncoding + { + Headers = new Dictionary + { + ["x-rate-limit"] = new OpenApiHeader + { + Description = "The number of allowed requests in the current period", + Schema = new OpenApiSchema + { + Type = JsonSchemaType.Integer + } + } + } + } + }, + Schema = new OpenApiSchema + { + Type = JsonSchemaType.Array, + Items = new OpenApiSchemaReference("Pet") + }, + Examples = new Dictionary + { + ["cat"] = new OpenApiExample + { + Summary = "An example cat", + Value = JsonValue.Create("Fluffy") + } + } + } + } + } + } + } + } + } + }, + Components = new OpenApiComponents + { + Schemas = new Dictionary + { + ["pet"] = new OpenApiSchema + { + Type = JsonSchemaType.Object, + Properties = new Dictionary + { + ["id"] = new OpenApiSchema { Type = JsonSchemaType.Integer, Format = "int64" }, + ["name"] = new OpenApiSchema { Type = JsonSchemaType.String }, + ["tag"] = new OpenApiSchema { Type = JsonSchemaType.String } + }, + Required = ["id", "name"] + } + }, + Parameters = new Dictionary + { + ["limit"] = new OpenApiParameter + { + Name = "limit", + In = ParameterLocation.Query, + Description = "How many items to return at one time (max 100)", + Required = false, + Schema = new OpenApiSchema + { + Type = JsonSchemaType.Integer, + Format = "int32" + } + } + }, + Responses = new OpenApiResponses + { + ["200"] = new OpenApiResponse + { + Description = "A list of pets.", + Content = new Dictionary + { + ["application/json"] = new OpenApiMediaType + { + Schema = new OpenApiSchema + { + Type = JsonSchemaType.Array, + Items = new OpenApiSchemaReference("Pet") + } + } + } + } + }, + RequestBodies = new Dictionary + { + ["pet"] = new OpenApiRequestBody + { + Content = new Dictionary + { + ["application/json"] = new OpenApiMediaType + { + Schema = new OpenApiSchemaReference("Pet") + } + } + } + }, + Links = new Dictionary + { + ["UserRepositories"] = new OpenApiLink + { + OperationId = "getRepositoriesByUsername", + Parameters = new Dictionary + { + ["username"] = new RuntimeExpressionAnyWrapper + { + Expression = RuntimeExpression.Build("$request.path.id") + } + } + } + }, + Headers = new Dictionary + { + ["x-rate-limit"] = new OpenApiHeader + { + Description = "The number of allowed requests in the current period", + Schema = new OpenApiSchema + { + Type = JsonSchemaType.Integer + } + } + }, + Examples = new Dictionary + { + ["cat"] = new OpenApiExample + { + Summary = "An example cat", + Value = JsonValue.Create("Fluffy") + } + }, + SecuritySchemes = new Dictionary + { + ["api_key"] = new OpenApiSecurityScheme + { + Type = SecuritySchemeType.ApiKey, + Name = "api_key", + In = ParameterLocation.Header + } + }, + Callbacks = new Dictionary + { + ["onData"] = new OpenApiCallback + { + PathItems = new Dictionary + { + [RuntimeExpression.Build("{$request.body#/callbackUrl}")] = new OpenApiPathItem + { + Operations = new Dictionary + { + [HttpMethod.Post] = new OpenApiOperation + { + Responses = new OpenApiResponses + { + ["200"] = new OpenApiResponse { Description = "ok" } + } + } + } + } + } + } + }, + PathItems = new Dictionary + { + ["/pets"] = new OpenApiPathItem + { + Operations = new Dictionary + { + [HttpMethod.Get] = new OpenApiOperation + { + Summary = "List all pets", + Responses = new OpenApiResponses + { + ["200"] = new OpenApiResponse + { + Description = "A list of pets.", + Content = new Dictionary + { + ["application/json"] = new OpenApiMediaType + { + Schema = new OpenApiSchema + { + Type = JsonSchemaType.Array, + Items = new OpenApiSchemaReference("Pet") + } + } + } + } + } + } + } + } + } + }, + Security = + [ + new OpenApiSecurityRequirement + { + { + new OpenApiSecuritySchemeReference("api_key"), + new List() + } + } + ], + Tags = + [ + new OpenApiTag + { + Name = "pets", + Description = "Operations related to pets" + } + ], + ExternalDocs = new OpenApiExternalDocs + { + Description = "Find out more", + Url = new Uri("https://example.com/docs") + } + }; + return doc; + } + } + +} diff --git a/test/Microsoft.OpenApi.Tests/Mocks/OpenApiDocumentSerializationTests.cs b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiDocumentSerializationTests.cs new file mode 100644 index 000000000..5f51ee23c --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiDocumentSerializationTests.cs @@ -0,0 +1,91 @@ +using System.IO; +using System.Linq; +using Microsoft.OpenApi.Models; +using Microsoft.OpenApi.Writers; +using Moq; +using Xunit; + +namespace Microsoft.OpenApi.Tests.Mocks +{ + public class OpenApiDocumentSerializationTests + { + // test for PathItems, servers + private static readonly OpenApiDocument _document = OpenApiDocumentMock.CreateCompleteOpenApiDocument(); + private static readonly Mock _pathItemMock = new() { CallBase = true }; + private static readonly Mock _webhookPathItemMock = new() { CallBase = true }; + private static readonly Mock _serverMock = new() { CallBase = true }; + private static readonly Mock _tagMock = new() { CallBase = true }; + private static readonly Mock _securityMock = new() { CallBase = true }; + private static readonly Mock _componentsMock = new() { CallBase = true }; + + public OpenApiDocumentSerializationTests() + { + _document.Paths["/pets"] = _pathItemMock.Object; + _document.Webhooks["pets"] = _webhookPathItemMock.Object; + _document.Servers[0] = _serverMock.Object; + _document.Tags.ToList()[0] = _tagMock.Object; + _document.Security[0] = _securityMock.Object; + _document.Components = _componentsMock.Object; + } + + [Fact] + public void SerializeAsV31_DoesNotCallV3OrV2Serialization() + { + // Arrange + using var stringWriter = new StringWriter(); + var writer = new OpenApiJsonWriter(stringWriter); + + // Act + _document.SerializeAsV31(writer); + + // Assert - fail if V2 or V3 methods are called + _pathItemMock.Verify(c => c.SerializeAsV3(It.IsAny()), Times.Never, "V3 method should not be called"); + _pathItemMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _webhookPathItemMock.Verify(c => c.SerializeAsV3(It.IsAny()), Times.Never, "V3 method should not be called"); + _webhookPathItemMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _tagMock.Verify(c => c.SerializeAsV3(It.IsAny()), Times.Never, "V3 method should not be called"); + _tagMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _serverMock.Verify(c => c.SerializeAsV3(It.IsAny()), Times.Never, "V3 method should not be called"); + _serverMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _securityMock.Verify(c => c.SerializeAsV3(It.IsAny()), Times.Never, "V3 method should not be called"); + _securityMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _componentsMock.Verify(c => c.SerializeAsV3(It.IsAny()), Times.Never, "V3 method should not be called"); + _componentsMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + } + + [Fact] + public void SerializeAsV3_DoesNotCallV31OrV2Serialization() + { + // Arrange + using var stringWriter = new StringWriter(); + var writer = new OpenApiJsonWriter(stringWriter); + + // Act + _document.SerializeAsV3(writer); + + // Assert - fail if V2 or V3 methods are called + _pathItemMock.Verify(c => c.SerializeAsV31(It.IsAny()), Times.Never, "V31 method should not be called"); + _pathItemMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _serverMock.Verify(c => c.SerializeAsV31(It.IsAny()), Times.Never, "V31 method should not be called"); + _serverMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _webhookPathItemMock.Verify(c => c.SerializeAsV31(It.IsAny()), Times.Never, "V31 method should not be called"); + _webhookPathItemMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _tagMock.Verify(c => c.SerializeAsV31(It.IsAny()), Times.Never, "V31 method should not be called"); + _tagMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _securityMock.Verify(c => c.SerializeAsV31(It.IsAny()), Times.Never, "V31 method should not be called"); + _securityMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _componentsMock.Verify(c => c.SerializeAsV31(It.IsAny()), Times.Never, "V31 method should not be called"); + _componentsMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + } + } +} diff --git a/test/Microsoft.OpenApi.Tests/Mocks/OpenApiEncodingSerializationTests.cs b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiEncodingSerializationTests.cs new file mode 100644 index 000000000..7838df745 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiEncodingSerializationTests.cs @@ -0,0 +1,51 @@ +using System.IO; +using System.Net.Http; +using Microsoft.OpenApi.Models; +using Microsoft.OpenApi.Writers; +using Moq; +using Xunit; + +namespace Microsoft.OpenApi.Tests.Mocks +{ + public class OpenApiEncodingSerializationTests + { + // test for header + private static readonly OpenApiEncoding _encoding = OpenApiDocumentMock.CreateCompleteOpenApiDocument().Paths["/pets"].Operations[HttpMethod.Get].Responses["200"].Content["application/json"].Encoding["x-rate-limit"]; + private static readonly Mock _headerMock = new() { CallBase = true }; + + public OpenApiEncodingSerializationTests() + { + _encoding.Headers["x-encoding"] = _headerMock.Object; + } + + [Fact] + public void SerializeAsV31_DoesNotCallV3OrV2Serialization() + { + // Arrange + using var stringWriter = new StringWriter(); + var writer = new OpenApiJsonWriter(stringWriter); + + // Act + _encoding.SerializeAsV31(writer); + + // Assert - fail if V2 or V3 methods are called + _headerMock.Verify(c => c.SerializeAsV3(It.IsAny()), Times.Never, "V3 method should not be called"); + _headerMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + } + + [Fact] + public void SerializeAsV3_DoesNotCallV31OrV2Serialization() + { + // Arrange + using var stringWriter = new StringWriter(); + var writer = new OpenApiJsonWriter(stringWriter); + + // Act + _encoding.SerializeAsV3(writer); + + // Assert - fail if V2 method is called + _headerMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + _headerMock.Verify(c => c.SerializeAsV31(It.IsAny()), Times.Never, "V31 method should not be called"); + } + } +} diff --git a/test/Microsoft.OpenApi.Tests/Mocks/OpenApiHeaderSerializationTests.cs b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiHeaderSerializationTests.cs new file mode 100644 index 000000000..f14721125 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiHeaderSerializationTests.cs @@ -0,0 +1,66 @@ +using System.IO; +using System.Net.Http; +using Microsoft.OpenApi.Models; +using Microsoft.OpenApi.Writers; +using Moq; +using Xunit; + +namespace Microsoft.OpenApi.Tests.Mocks +{ + public class OpenApiHeaderSerializationTests + { + private static readonly OpenApiHeader _header = (OpenApiHeader)OpenApiDocumentMock.CreateCompleteOpenApiDocument().Paths["/pets"].Operations[HttpMethod.Get].Responses["200"].Headers["x-rate-limit"]; + private static readonly Mock _schemaMock = new() { CallBase = true }; + private static readonly Mock _exampleMock = new() { CallBase = true }; + private static readonly Mock _mediaTypeMock = new() { CallBase = true }; + + public OpenApiHeaderSerializationTests() + { + _header.Schema = _schemaMock.Object; + _header.Examples["cat"] = _exampleMock.Object; + _header.Content["application/json"] = _mediaTypeMock.Object; + } + + [Fact] + public void SerializeAsV31_DoesNotCallV3OrV2Serialization() + { + // Arrange + using var stringWriter = new StringWriter(); + var writer = new OpenApiJsonWriter(stringWriter); + + // Act + _header.SerializeAsV31(writer); + + // Assert + _schemaMock.Verify(h => h.SerializeAsV3(It.IsAny()), Times.Never); + _schemaMock.Verify(h => h.SerializeAsV2(It.IsAny()), Times.Never); + + _exampleMock.Verify(h => h.SerializeAsV3(It.IsAny()), Times.Never); + _exampleMock.Verify(h => h.SerializeAsV2(It.IsAny()), Times.Never); + + _mediaTypeMock.Verify(h => h.SerializeAsV3(It.IsAny()), Times.Never); + _mediaTypeMock.Verify(h => h.SerializeAsV2(It.IsAny()), Times.Never); + } + + [Fact] + public void SerializeAsV3_DoesNotCallV2Serialization() + { + // Arrange + using var stringWriter = new StringWriter(); + var writer = new OpenApiJsonWriter(stringWriter); + + // Act + _header.SerializeAsV3(writer); + + // Assert + _schemaMock.Verify(h => h.SerializeAsV31(It.IsAny()), Times.Never); + _schemaMock.Verify(h => h.SerializeAsV2(It.IsAny()), Times.Never); + + _exampleMock.Verify(h => h.SerializeAsV31(It.IsAny()), Times.Never); + _exampleMock.Verify(h => h.SerializeAsV2(It.IsAny()), Times.Never); + + _mediaTypeMock.Verify(h => h.SerializeAsV31(It.IsAny()), Times.Never); + _mediaTypeMock.Verify(h => h.SerializeAsV2(It.IsAny()), Times.Never); + } + } +} diff --git a/test/Microsoft.OpenApi.Tests/Mocks/OpenApiInfoSerializationTests.cs b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiInfoSerializationTests.cs new file mode 100644 index 000000000..686e68021 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiInfoSerializationTests.cs @@ -0,0 +1,57 @@ +using System.IO; +using Microsoft.OpenApi.Models; +using Microsoft.OpenApi.Writers; +using Moq; +using Xunit; + +namespace Microsoft.OpenApi.Tests.Mocks +{ + public class OpenApiInfoSerializationTests + { + private static readonly OpenApiInfo _info = OpenApiDocumentMock.CreateCompleteOpenApiDocument().Info; + private static readonly Mock _contactMock = new() { CallBase = true }; + private static readonly Mock _licenseMock = new() { CallBase = true }; + + public OpenApiInfoSerializationTests() + { + _info.Contact = _contactMock.Object; + _info.License = _licenseMock.Object; + } + + [Fact] + public void SerializeAsV31_DoesNotCallV3OrV2Serialization() + { + // Arrange + using var stringWriter = new StringWriter(); + var writer = new OpenApiJsonWriter(stringWriter); + + // Act + _info.SerializeAsV31(writer); + + // Assert - fail if V2 or V3 methods are called + _contactMock.Verify(c => c.SerializeAsV3(It.IsAny()), Times.Never, "V3 method should not be called"); + _contactMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _licenseMock.Verify(l => l.SerializeAsV3(It.IsAny()), Times.Never, "V3 method should not be called"); + _licenseMock.Verify(l => l.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + } + + [Fact] + public void SerializeAsV3_DoesNotCallV31OrV2Serialization() + { + // Arrange + using var stringWriter = new StringWriter(); + var writer = new OpenApiJsonWriter(stringWriter); + + // Act + _info.SerializeAsV3(writer); + + // Assert - fail if V2 or V3 methods are called + _contactMock.Verify(c => c.SerializeAsV31(It.IsAny()), Times.Never, "V31 method should not be called"); + _contactMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _licenseMock.Verify(l => l.SerializeAsV31(It.IsAny()), Times.Never, "V31 method should not be called"); + _licenseMock.Verify(l => l.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + } + } +} diff --git a/test/Microsoft.OpenApi.Tests/Mocks/OpenApiMediaTypeSerializationTests.cs b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiMediaTypeSerializationTests.cs new file mode 100644 index 000000000..b4f9b8d86 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiMediaTypeSerializationTests.cs @@ -0,0 +1,67 @@ +using System.IO; +using System.Net.Http; +using Microsoft.OpenApi.Models; +using Microsoft.OpenApi.Writers; +using Moq; +using Xunit; + +namespace Microsoft.OpenApi.Tests.Mocks +{ + public class OpenApiMediaTypeSerializationTests + { + private static readonly OpenApiMediaType _mediaType = OpenApiDocumentMock.CreateCompleteOpenApiDocument().Paths["/pets"].Operations[HttpMethod.Get].Responses["200"].Content["application/json"]; + private static readonly Mock _schemaMock = new() { CallBase = true }; + private static readonly Mock _encodingMock = new() { CallBase = true }; + private static readonly Mock _exampleMock = new() { CallBase = true }; + + public OpenApiMediaTypeSerializationTests() + { + _mediaType.Schema = _schemaMock.Object; + _mediaType.Examples["cat"] = _exampleMock.Object; + _mediaType.Examples["example"] = _exampleMock.Object; + _mediaType.Encoding["encoding"] = _encodingMock.Object; + } + + [Fact] + public void SerializeAsV31_DoesNotCallV3OrV2Serialization() + { + // Arrange + using var stringWriter = new StringWriter(); + var writer = new OpenApiJsonWriter(stringWriter); + + // Act + _mediaType.SerializeAsV31(writer); + + // Assert - fail if V2 or V3 methods are called + _schemaMock.Verify(c => c.SerializeAsV3(It.IsAny()), Times.Never, "V3 method should not be called"); + _schemaMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _encodingMock.Verify(c => c.SerializeAsV3(It.IsAny()), Times.Never, "V3 method should not be called"); + _encodingMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _exampleMock.Verify(c => c.SerializeAsV3(It.IsAny()), Times.Never, "V3 method should not be called"); + _exampleMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + } + + [Fact] + public void SerializeAsV3_DoesNotCallV31OrV2Serialization() + { + // Arrange + using var stringWriter = new StringWriter(); + var writer = new OpenApiJsonWriter(stringWriter); + + // Act + _mediaType.SerializeAsV3(writer); + + // Assert - fail if V2 or V3 methods are called + _schemaMock.Verify(c => c.SerializeAsV31(It.IsAny()), Times.Never, "V31 method should not be called"); + _schemaMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _encodingMock.Verify(c => c.SerializeAsV31(It.IsAny()), Times.Never, "V31 method should not be called"); + _encodingMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _exampleMock.Verify(c => c.SerializeAsV31(It.IsAny()), Times.Never, "V31 method should not be called"); + _exampleMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + } + } +} diff --git a/test/Microsoft.OpenApi.Tests/Mocks/OpenApiOperationSerializationTests.cs b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiOperationSerializationTests.cs new file mode 100644 index 000000000..d267d1461 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiOperationSerializationTests.cs @@ -0,0 +1,101 @@ +using System.IO; +using System.Linq; +using System.Net.Http; +using Microsoft.OpenApi.Models; +using Microsoft.OpenApi.Models.References; +using Microsoft.OpenApi.Writers; +using Moq; +using Xunit; + +namespace Microsoft.OpenApi.Tests.Mocks +{ + public class OpenApiOperationSerializationTests + { + private static readonly OpenApiOperation _operation = OpenApiDocumentMock.CreateCompleteOpenApiDocument().Paths["/pets"].Operations[HttpMethod.Get]; + + private static readonly Mock _callbackMock = new() { CallBase = true }; + private static readonly Mock _pathItemMock = new() { CallBase = true }; + private static readonly Mock _requestBodyMock = new() { CallBase = true }; + private static readonly Mock _responsesMock = new() { CallBase = true }; + private static readonly Mock _parameterMock = new() { CallBase = true }; + private static readonly Mock _securityRequirementMock = new() { CallBase = true }; + private static readonly Mock _tagMock = new() { CallBase = true }; + + + public OpenApiOperationSerializationTests() + { + _operation.Callbacks["onData"] = _callbackMock.Object; + _operation.Responses["200"] = _responsesMock.Object; + _operation.RequestBody = _requestBodyMock.Object; + _operation.Parameters[0] = _parameterMock.Object; + _operation.Security[0] = _securityRequirementMock.Object; + _operation.Tags.ToList()[0] = _tagMock.Object; + } + + [Fact] + public void SerializeAsV31_DoesNotCallV3OrV2Serialization() + { + // Arrange + using var stringWriter = new StringWriter(); + var writer = new OpenApiJsonWriter(stringWriter); + + // Act + _operation.SerializeAsV31(writer); + + // Assert - fail if V2 or V3 methods are called + _callbackMock.Verify(c => c.SerializeAsV3(It.IsAny()), Times.Never, "V3 method should not be called"); + _callbackMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _pathItemMock.Verify(c => c.SerializeAsV3(It.IsAny()), Times.Never, "V3 method should not be called"); + _pathItemMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _requestBodyMock.Verify(c => c.SerializeAsV3(It.IsAny()), Times.Never, "V3 method should not be called"); + _requestBodyMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _responsesMock.Verify(c => c.SerializeAsV3(It.IsAny()), Times.Never, "V3 method should not be called"); + _responsesMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _parameterMock.Verify(c => c.SerializeAsV3(It.IsAny()), Times.Never, "V3 method should not be called"); + _parameterMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _securityRequirementMock.Verify(c => c.SerializeAsV3(It.IsAny()), Times.Never, "V3 method should not be called"); + _securityRequirementMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _tagMock.Verify(c => c.SerializeAsV3(It.IsAny()), Times.Never, "V3 method should not be called"); + _tagMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + } + + [Fact] + public void SerializeAsV3_DoesNotCallV31OrV2Serialization() + { + // Arrange + using var stringWriter = new StringWriter(); + var writer = new OpenApiJsonWriter(stringWriter); + + // Act + _operation.SerializeAsV3(writer); + + // Assert - fail if V2 or V3 methods are called + _callbackMock.Verify(c => c.SerializeAsV31(It.IsAny()), Times.Never, "V31 method should not be called"); + _callbackMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _pathItemMock.Verify(c => c.SerializeAsV31(It.IsAny()), Times.Never, "V31 method should not be called"); + _pathItemMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _requestBodyMock.Verify(c => c.SerializeAsV31(It.IsAny()), Times.Never, "V31 method should not be called"); + _requestBodyMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _responsesMock.Verify(c => c.SerializeAsV31(It.IsAny()), Times.Never, "V31 method should not be called"); + _responsesMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _parameterMock.Verify(c => c.SerializeAsV31(It.IsAny()), Times.Never, "V31 method should not be called"); + _parameterMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _securityRequirementMock.Verify(c => c.SerializeAsV31(It.IsAny()), Times.Never, "V31 method should not be called"); + _securityRequirementMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _tagMock.Verify(c => c.SerializeAsV31(It.IsAny()), Times.Never, "V31 method should not be called"); + _tagMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + } + } +} diff --git a/test/Microsoft.OpenApi.Tests/Mocks/OpenApiParameterSerializationTests.cs b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiParameterSerializationTests.cs new file mode 100644 index 000000000..76b32354f --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiParameterSerializationTests.cs @@ -0,0 +1,65 @@ +using System.IO; +using Microsoft.OpenApi.Models; +using Microsoft.OpenApi.Writers; +using Moq; +using Xunit; + +namespace Microsoft.OpenApi.Tests.Mocks +{ + public class OpenApiParameterSerializationTests + { + private static readonly OpenApiParameter _parameter = (OpenApiParameter)OpenApiDocumentMock.CreateCompleteOpenApiDocument().Paths["/pets"].Parameters[0]; + private static readonly Mock _schemaMock = new() { CallBase = true }; + private static readonly Mock _contentMock = new() { CallBase = true }; + private static readonly Mock _exampleMock = new() { CallBase = true }; + + public OpenApiParameterSerializationTests() + { + _parameter.Schema = _schemaMock.Object; + _parameter.Content["application/json"] = _contentMock.Object; + _parameter.Examples["example"] = _exampleMock.Object; + } + + [Fact] + public void SerializeAsV31_DoesNotCallV3OrV2Serialization() + { + // Arrange + using var stringWriter = new StringWriter(); + var writer = new OpenApiJsonWriter(stringWriter); + + // Act + _parameter.SerializeAsV31(writer); + + // Assert - fail if V2 or V3 methods are called + _schemaMock.Verify(c => c.SerializeAsV3(It.IsAny()), Times.Never, "V3 method should not be called"); + _schemaMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _contentMock.Verify(c => c.SerializeAsV3(It.IsAny()), Times.Never, "V3 method should not be called"); + _contentMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _exampleMock.Verify(c => c.SerializeAsV3(It.IsAny()), Times.Never, "V3 method should not be called"); + _exampleMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + } + + [Fact] + public void SerializeAsV3_DoesNotCallV31OrV2Serialization() + { + // Arrange + using var stringWriter = new StringWriter(); + var writer = new OpenApiJsonWriter(stringWriter); + + // Act + _parameter.SerializeAsV3(writer); + + // Assert - fail if V2 or V3 methods are called + _schemaMock.Verify(c => c.SerializeAsV31(It.IsAny()), Times.Never, "V31 method should not be called"); + _schemaMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _contentMock.Verify(c => c.SerializeAsV31(It.IsAny()), Times.Never, "V31 method should not be called"); + _contentMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _exampleMock.Verify(c => c.SerializeAsV31(It.IsAny()), Times.Never, "V31 method should not be called"); + _exampleMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + } + } +} diff --git a/test/Microsoft.OpenApi.Tests/Mocks/OpenApiPathItemSerializationTests.cs b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiPathItemSerializationTests.cs new file mode 100644 index 000000000..3b1339172 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiPathItemSerializationTests.cs @@ -0,0 +1,67 @@ +using System.IO; +using System.Net.Http; +using Microsoft.OpenApi.Models; +using Microsoft.OpenApi.Models.Interfaces; +using Microsoft.OpenApi.Writers; +using Moq; +using Xunit; + +namespace Microsoft.OpenApi.Tests.Mocks +{ + public class OpenApiPathItemSerializationTests + { + private static readonly IOpenApiPathItem _pathItem = OpenApiDocumentMock.CreateCompleteOpenApiDocument().Paths["/pets"]; + private static readonly Mock _operationMock = new() { CallBase = true }; + private static readonly Mock _serverMock = new() { CallBase = true }; + private static readonly Mock _parameterMock = new() { CallBase = true }; + + public OpenApiPathItemSerializationTests() + { + _pathItem.Operations[HttpMethod.Get] = _operationMock.Object; + _pathItem.Servers[0] = _serverMock.Object ; + _pathItem.Parameters[0] = _parameterMock.Object; + } + + [Fact] + public void SerializeAsV31_DoesNotCallV3OrV2Serialization() + { + // Arrange + using var stringWriter = new StringWriter(); + var writer = new OpenApiJsonWriter(stringWriter); + + // Act + _pathItem.SerializeAsV31(writer); + + // Assert - fail if V2 or V3 methods are called + _operationMock.Verify(c => c.SerializeAsV3(It.IsAny()), Times.Never, "V3 method should not be called"); + _operationMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _serverMock.Verify(c => c.SerializeAsV3(It.IsAny()), Times.Never, "V3 method should not be called"); + _serverMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _parameterMock.Verify(c => c.SerializeAsV3(It.IsAny()), Times.Never, "V3 method should not be called"); + _parameterMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + } + + [Fact] + public void SerializeAsV3_DoesNotCallV31OrV2Serialization() + { + // Arrange + using var stringWriter = new StringWriter(); + var writer = new OpenApiJsonWriter(stringWriter); + + // Act + _pathItem.SerializeAsV3(writer); + + // Assert - fail if V2 or V3 methods are called + _operationMock.Verify(c => c.SerializeAsV31(It.IsAny()), Times.Never, "V31 method should not be called"); + _operationMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _serverMock.Verify(c => c.SerializeAsV31(It.IsAny()), Times.Never, "V31 method should not be called"); + _serverMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + + _parameterMock.Verify(c => c.SerializeAsV31(It.IsAny()), Times.Never, "V31 method should not be called"); + _parameterMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + } + } +} diff --git a/test/Microsoft.OpenApi.Tests/Mocks/OpenApiRequestBodySerializationTests.cs b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiRequestBodySerializationTests.cs new file mode 100644 index 000000000..79cff9050 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiRequestBodySerializationTests.cs @@ -0,0 +1,51 @@ +using System.IO; +using System.Net.Http; +using Microsoft.OpenApi.Models; +using Microsoft.OpenApi.Models.Interfaces; +using Microsoft.OpenApi.Writers; +using Moq; +using Xunit; + +namespace Microsoft.OpenApi.Tests.Mocks +{ + public class OpenApiRequestBodySerializationTests + { + private static readonly IOpenApiRequestBody _requestBody = OpenApiDocumentMock.CreateCompleteOpenApiDocument().Paths["/pets"].Operations[HttpMethod.Get].RequestBody; + private static readonly Mock _mediaTypeMock = new() { CallBase = true }; + + public OpenApiRequestBodySerializationTests() + { + _requestBody.Content["application/json"] = _mediaTypeMock.Object; + } + + [Fact] + public void SerializeAsV31_DoesNotCallV3OrV2Serialization() + { + // Arrange + using var stringWriter = new StringWriter(); + var writer = new OpenApiJsonWriter(stringWriter); + + // Act + _requestBody.SerializeAsV31(writer); + + // Assert - fail if V2 or V3 methods are called + _mediaTypeMock.Verify(c => c.SerializeAsV3(It.IsAny()), Times.Never, "V3 method should not be called"); + _mediaTypeMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + } + + [Fact] + public void SerializeAsV3_DoesNotCallV31OrV2Serialization() + { + // Arrange + using var stringWriter = new StringWriter(); + var writer = new OpenApiJsonWriter(stringWriter); + + // Act + _requestBody.SerializeAsV3(writer); + + // Assert - fail if V2 or V3 methods are called + _mediaTypeMock.Verify(c => c.SerializeAsV31(It.IsAny()), Times.Never, "V31 method should not be called"); + _mediaTypeMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + } + } +} diff --git a/test/Microsoft.OpenApi.Tests/Mocks/OpenApiResponseSerializationTests.cs b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiResponseSerializationTests.cs new file mode 100644 index 000000000..29df27f33 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiResponseSerializationTests.cs @@ -0,0 +1,67 @@ +using System.IO; +using System.Net.Http; +using Microsoft.OpenApi.Models; +using Microsoft.OpenApi.Models.Interfaces; +using Microsoft.OpenApi.Writers; +using Moq; +using Xunit; + +namespace Microsoft.OpenApi.Tests.Mocks +{ + public class OpenApiResponseSerializationTests + { + private static readonly IOpenApiResponse _response = OpenApiDocumentMock.CreateCompleteOpenApiDocument().Paths["/pets"].Operations[HttpMethod.Get].Responses["200"]; + private static readonly Mock _headerMock = new() { CallBase = true }; + private static readonly Mock _mediaTypeMock = new() { CallBase = true }; + private static readonly Mock _linkMock = new() { CallBase = true }; + + public OpenApiResponseSerializationTests() + { + _response.Headers["x-rate-limit"] = _headerMock.Object; + _response.Content["application/json"] = _mediaTypeMock.Object; + _response.Links["UserRepositories"] = _linkMock.Object; + } + + [Fact] + public void SerializeAsV31_DoesNotCallV3OrV2Serialization() + { + // Arrange + using var stringWriter = new StringWriter(); + var writer = new OpenApiJsonWriter(stringWriter); + + // Act + _response.SerializeAsV31(writer); + + // Assert + _headerMock.Verify(h => h.SerializeAsV3(It.IsAny()), Times.Never); + _headerMock.Verify(h => h.SerializeAsV2(It.IsAny()), Times.Never); + + _mediaTypeMock.Verify(m => m.SerializeAsV3(It.IsAny()), Times.Never); + _mediaTypeMock.Verify(m => m.SerializeAsV2(It.IsAny()), Times.Never); + + _linkMock.Verify(l => l.SerializeAsV3(It.IsAny()), Times.Never); + _linkMock.Verify(l => l.SerializeAsV2(It.IsAny()), Times.Never); + } + + [Fact] + public void SerializeAsV3_DoesNotCallV31OrV2Serialization() + { + // Arrange + using var stringWriter = new StringWriter(); + var writer = new OpenApiJsonWriter(stringWriter); + + // Act + _response.SerializeAsV3(writer); + + // Assert + _headerMock.Verify(h => h.SerializeAsV31(It.IsAny()), Times.Never); + _headerMock.Verify(h => h.SerializeAsV2(It.IsAny()), Times.Never); + + _mediaTypeMock.Verify(m => m.SerializeAsV31(It.IsAny()), Times.Never); + _mediaTypeMock.Verify(m => m.SerializeAsV2(It.IsAny()), Times.Never); + + _linkMock.Verify(l => l.SerializeAsV31(It.IsAny()), Times.Never); + _linkMock.Verify(l => l.SerializeAsV2(It.IsAny()), Times.Never); + } + } +} diff --git a/test/Microsoft.OpenApi.Tests/Mocks/OpenApiSchemaSerializationTests.cs b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiSchemaSerializationTests.cs new file mode 100644 index 000000000..2cc0eca8b --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiSchemaSerializationTests.cs @@ -0,0 +1,50 @@ +using System.IO; +using System.Net.Http; +using Microsoft.OpenApi.Models; +using Microsoft.OpenApi.Writers; +using Moq; +using Xunit; + +namespace Microsoft.OpenApi.Tests.Mocks +{ + public class OpenApiSchemaSerializationTests + { + private static readonly OpenApiSchema _schema = (OpenApiSchema)OpenApiDocumentMock.CreateCompleteOpenApiDocument().Paths["/pets"].Operations[HttpMethod.Get].RequestBody.Content["application/xml"].Schema; + private static readonly Mock _xmlMock = new() { CallBase = true }; + + public OpenApiSchemaSerializationTests() + { + _schema.Xml = _xmlMock.Object; + } + + [Fact] + public void SerializeAsV31_DoesNotCallV3OrV2Serialization() + { + // Arrange + using var stringWriter = new StringWriter(); + var writer = new OpenApiJsonWriter(stringWriter); + + // Act + _schema.SerializeAsV31(writer); + + // Assert - fail if V2 or V3 methods are called + _xmlMock.Verify(c => c.SerializeAsV3(It.IsAny()), Times.Never, "V3 method should not be called"); + _xmlMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + } + + [Fact] + public void SerializeAsV3_DoesNotCallV31OrV2Serialization() + { + // Arrange + using var stringWriter = new StringWriter(); + var writer = new OpenApiJsonWriter(stringWriter); + + // Act + _schema.SerializeAsV3(writer); + + // Assert - fail if V2 method is called + _xmlMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + _xmlMock.Verify(c => c.SerializeAsV31(It.IsAny()), Times.Never, "V31 method should not be called"); + } + } +} diff --git a/test/Microsoft.OpenApi.Tests/Mocks/OpenApiSecuritySchemeSerializationTests.cs b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiSecuritySchemeSerializationTests.cs new file mode 100644 index 000000000..aced889b0 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiSecuritySchemeSerializationTests.cs @@ -0,0 +1,49 @@ +using System.IO; +using Microsoft.OpenApi.Models; +using Microsoft.OpenApi.Writers; +using Moq; +using Xunit; + +namespace Microsoft.OpenApi.Tests.Mocks +{ + public class OpenApiSecuritySchemeSerializationTests + { + private static readonly OpenApiSecurityScheme _securityScheme = (OpenApiSecurityScheme)OpenApiDocumentMock.CreateCompleteOpenApiDocument().Components.SecuritySchemes["api_key"]; + private static readonly Mock _authFlowMock = new() { CallBase = true }; + + public OpenApiSecuritySchemeSerializationTests() + { + _securityScheme.Flows = _authFlowMock.Object; + } + + [Fact] + public void SerializeAsV31_DoesNotCallV3OrV2Serialization() + { + // Arrange + using var stringWriter = new StringWriter(); + var writer = new OpenApiJsonWriter(stringWriter); + + // Act + _securityScheme.SerializeAsV31(writer); + + // Assert + _authFlowMock.Verify(c => c.SerializeAsV3(It.IsAny()), Times.Never, "V3 method should not be called"); + _authFlowMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + } + + [Fact] + public void SerializeAsV3_DoesNotCallV31OrV2Serialization() + { + // Arrange + using var stringWriter = new StringWriter(); + var writer = new OpenApiJsonWriter(stringWriter); + + // Act + _securityScheme.SerializeAsV3(writer); + + // Assert + _authFlowMock.Verify(c => c.SerializeAsV31(It.IsAny()), Times.Never, "V31 method should not be called"); + _authFlowMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + } + } +} diff --git a/test/Microsoft.OpenApi.Tests/Mocks/OpenApiTagsSerialization.cs b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiTagsSerialization.cs new file mode 100644 index 000000000..1d0997f53 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiTagsSerialization.cs @@ -0,0 +1,50 @@ +using System.IO; +using System.Linq; +using Microsoft.OpenApi.Models; +using Microsoft.OpenApi.Writers; +using Moq; +using Xunit; + +namespace Microsoft.OpenApi.Tests.Mocks +{ + public class OpenApiTagsSerialization + { + private static readonly OpenApiTag _tag = OpenApiDocumentMock.CreateCompleteOpenApiDocument().Tags.ToList()[0]; + private static readonly Mock _externalDocsMock = new() { CallBase = true }; + + public OpenApiTagsSerialization() + { + _tag.ExternalDocs = _externalDocsMock.Object; + } + + [Fact] + public void SerializeAsV31_DoesNotCallV3OrV2Serialization() + { + // Arrange + using var stringWriter = new StringWriter(); + var writer = new OpenApiJsonWriter(stringWriter); + + // Act + _tag.SerializeAsV31(writer); + + // Assert - fail if V2 or V3 methods are called + _externalDocsMock.Verify(c => c.SerializeAsV3(It.IsAny()), Times.Never, "V3 method should not be called"); + _externalDocsMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + } + + [Fact] + public void SerializeAsV3_DoesNotCallV31OrV2Serialization() + { + // Arrange + using var stringWriter = new StringWriter(); + var writer = new OpenApiJsonWriter(stringWriter); + + // Act + _tag.SerializeAsV3(writer); + + // Assert - fail if V2 method is called + _externalDocsMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); + _externalDocsMock.Verify(c => c.SerializeAsV31(It.IsAny()), Times.Never, "V31 method should not be called"); + } + } +} From 3c8224ad253fb29088f4dcfeb9d64446f50eb54f Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Mon, 28 Apr 2025 17:37:23 +0300 Subject: [PATCH 110/984] fix: routing issue --- src/Microsoft.OpenApi/Models/OpenApiMediaType.cs | 6 +++--- src/Microsoft.OpenApi/Models/OpenApiSchema.cs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs b/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs index 711b0c71e..f71377866 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs @@ -99,7 +99,7 @@ private void SerializeInternal(IOpenApiWriter writer, OpenApiSpecVersion version // examples if (Examples != null && Examples.Any()) { - SerializeExamples(writer, Examples); + SerializeExamples(writer, Examples, callback); } // encoding @@ -119,7 +119,7 @@ public virtual void SerializeAsV2(IOpenApiWriter writer) // Media type does not exist in V2. } - private static void SerializeExamples(IOpenApiWriter writer, Dictionary examples) + private static void SerializeExamples(IOpenApiWriter writer, Dictionary examples, Action callback) { /* Special case for writing out empty arrays as valid response examples * Check if there is any example with an empty array as its value and set the flag `hasEmptyArray` to true @@ -143,7 +143,7 @@ private static void SerializeExamples(IOpenApiWriter writer, Dictionary e.SerializeAsV3(w)); + writer.WriteOptionalMap(OpenApiConstants.Examples, examples, callback); } } } diff --git a/src/Microsoft.OpenApi/Models/OpenApiSchema.cs b/src/Microsoft.OpenApi/Models/OpenApiSchema.cs index 2cadb1122..bd78e8f9c 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiSchema.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiSchema.cs @@ -490,7 +490,7 @@ private void SerializeInternal(IOpenApiWriter writer, OpenApiSpecVersion version writer.WriteProperty(OpenApiConstants.WriteOnly, WriteOnly, false); // xml - writer.WriteOptionalObject(OpenApiConstants.Xml, Xml, (w, s) => s.SerializeAsV2(w)); + writer.WriteOptionalObject(OpenApiConstants.Xml, Xml, callback); // externalDocs writer.WriteOptionalObject(OpenApiConstants.ExternalDocs, ExternalDocs, callback); From a48f91a8dd1619a1f5fd47bd36368ebefb8af2d4 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Mon, 28 Apr 2025 17:37:59 +0300 Subject: [PATCH 111/984] fix: mark methods as virtual for overriding --- src/Microsoft.OpenApi/Models/OpenApiComponents.cs | 6 +++--- src/Microsoft.OpenApi/Models/OpenApiSecurityRequirement.cs | 6 +++--- src/Microsoft.OpenApi/Models/OpenApiTag.cs | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Microsoft.OpenApi/Models/OpenApiComponents.cs b/src/Microsoft.OpenApi/Models/OpenApiComponents.cs index fb0129bec..765a6ee53 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiComponents.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiComponents.cs @@ -98,7 +98,7 @@ public OpenApiComponents(OpenApiComponents? components) /// Serialize to Open API v3.1. /// /// - public void SerializeAsV31(IOpenApiWriter writer) + public virtual void SerializeAsV31(IOpenApiWriter writer) { Utils.CheckArgumentNull(writer); @@ -136,7 +136,7 @@ public void SerializeAsV31(IOpenApiWriter writer) /// Serialize to v3.0 /// /// - public void SerializeAsV3(IOpenApiWriter writer) + public virtual void SerializeAsV3(IOpenApiWriter writer) { Utils.CheckArgumentNull(writer); @@ -338,7 +338,7 @@ private void RenderComponents(IOpenApiWriter writer, Action /// Serialize to Open Api v2.0. /// - public void SerializeAsV2(IOpenApiWriter writer) + public virtual void SerializeAsV2(IOpenApiWriter writer) { // Components object does not exist in V2. } diff --git a/src/Microsoft.OpenApi/Models/OpenApiSecurityRequirement.cs b/src/Microsoft.OpenApi/Models/OpenApiSecurityRequirement.cs index f9d40682b..c76f33671 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiSecurityRequirement.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiSecurityRequirement.cs @@ -35,7 +35,7 @@ public OpenApiSecurityRequirement() /// /// Serialize to Open Api v3.1 /// - public void SerializeAsV31(IOpenApiWriter writer) + public virtual void SerializeAsV31(IOpenApiWriter writer) { SerializeInternal(writer, (w, s) => { @@ -49,7 +49,7 @@ public void SerializeAsV31(IOpenApiWriter writer) /// /// Serialize to Open Api v3.0 /// - public void SerializeAsV3(IOpenApiWriter writer) + public virtual void SerializeAsV3(IOpenApiWriter writer) { SerializeInternal(writer, (w, s) => { @@ -96,7 +96,7 @@ private void SerializeInternal(IOpenApiWriter writer, Action /// Serialize to Open Api v2.0 /// - public void SerializeAsV2(IOpenApiWriter writer) + public virtual void SerializeAsV2(IOpenApiWriter writer) { SerializeInternal(writer, (w, s) => s.SerializeAsV2(w)); } diff --git a/src/Microsoft.OpenApi/Models/OpenApiTag.cs b/src/Microsoft.OpenApi/Models/OpenApiTag.cs index 253fab1de..74adcb2fe 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiTag.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiTag.cs @@ -46,7 +46,7 @@ internal OpenApiTag(IOpenApiTag tag) /// /// Serialize to Open Api v3.1 /// - public void SerializeAsV31(IOpenApiWriter writer) + public virtual void SerializeAsV31(IOpenApiWriter writer) { SerializeInternal(writer, OpenApiSpecVersion.OpenApi3_1, (writer, element) => element.SerializeAsV31(writer)); @@ -55,7 +55,7 @@ public void SerializeAsV31(IOpenApiWriter writer) /// /// Serialize to Open Api v3.0 /// - public void SerializeAsV3(IOpenApiWriter writer) + public virtual void SerializeAsV3(IOpenApiWriter writer) { SerializeInternal(writer, OpenApiSpecVersion.OpenApi3_0, (writer, element) => element.SerializeAsV3(writer)); @@ -84,7 +84,7 @@ internal void SerializeInternal(IOpenApiWriter writer, OpenApiSpecVersion versio /// /// Serialize to Open Api v2.0 /// - public void SerializeAsV2(IOpenApiWriter writer) + public virtual void SerializeAsV2(IOpenApiWriter writer) { writer.WriteStartObject(); From 06fffa23a35522523de1df96b902565190df9111 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Mon, 28 Apr 2025 17:38:19 +0300 Subject: [PATCH 112/984] chore: clean up tests --- .../OpenApiCallbackSerializationTests.cs | 5 +- .../OpenApiComponentsSerializationTests.cs | 23 +-- .../Mocks/OpenApiDocumentMock.cs | 41 +++++- .../OpenApiDocumentSerializationTests.cs | 16 +-- .../OpenApiEncodingSerializationTests.cs | 6 +- .../Mocks/OpenApiHeaderSerializationTests.cs | 9 +- .../Mocks/OpenApiInfoSerializationTests.cs | 7 +- .../OpenApiMediaTypeSerializationTests.cs | 9 +- .../OpenApiOperationSerializationTests.cs | 24 ++-- .../OpenApiParameterSerializationTests.cs | 9 +- .../OpenApiPathItemSerializationTests.cs | 9 +- .../OpenApiRequestBodySerializationTests.cs | 5 +- .../OpenApiResponseSerializationTests.cs | 9 +- .../Mocks/OpenApiSchemaSerializationTests.cs | 5 +- ...OpenApiSecuritySchemeSerializationTests.cs | 5 +- .../Mocks/OpenApiTagsSerialization.cs | 5 +- .../PublicApi/PublicApi.approved.txt | 132 +++++++++--------- 17 files changed, 178 insertions(+), 141 deletions(-) diff --git a/test/Microsoft.OpenApi.Tests/Mocks/OpenApiCallbackSerializationTests.cs b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiCallbackSerializationTests.cs index 70d61f7d0..c9d171ed7 100644 --- a/test/Microsoft.OpenApi.Tests/Mocks/OpenApiCallbackSerializationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiCallbackSerializationTests.cs @@ -10,11 +10,12 @@ namespace Microsoft.OpenApi.Tests.Mocks { public class OpenApiCallbackSerializationTests { - private static readonly OpenApiCallback _callback = (OpenApiCallback)OpenApiDocumentMock.CreateCompleteOpenApiDocument().Paths["/pets"].Operations[HttpMethod.Get].Callbacks["onData"]; - private static readonly Mock _pathItemMock = new() { CallBase = true }; + private readonly OpenApiCallback _callback; + private readonly Mock _pathItemMock = new() { CallBase = true }; public OpenApiCallbackSerializationTests() { + _callback = (OpenApiCallback)OpenApiDocumentMock.CreateCompleteOpenApiDocument().Paths["/pets"].Operations[HttpMethod.Get].Callbacks["onData"]; _callback.PathItems[RuntimeExpression.Build("{$request.body#/callbackUrl}")] = _pathItemMock.Object; } diff --git a/test/Microsoft.OpenApi.Tests/Mocks/OpenApiComponentsSerializationTests.cs b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiComponentsSerializationTests.cs index 785739028..f68d0d988 100644 --- a/test/Microsoft.OpenApi.Tests/Mocks/OpenApiComponentsSerializationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiComponentsSerializationTests.cs @@ -8,20 +8,21 @@ namespace Microsoft.OpenApi.Tests.Mocks { public class OpenApiComponentsSerializationTests { - private static readonly OpenApiComponents _components = OpenApiDocumentMock.CreateCompleteOpenApiDocument().Components; - private static readonly Mock _schemaMock = new() { CallBase = true }; - private static readonly Mock _requestBodyMock = new() { CallBase = true }; - private static readonly Mock _responseMock = new() { CallBase = true }; - private static readonly Mock _parameterMock = new() { CallBase = true }; - private static readonly Mock _headerMock = new() { CallBase = true }; - private static readonly Mock _securitySchemeMock = new() { CallBase = true }; - private static readonly Mock _linkMock = new() { CallBase = true }; - private static readonly Mock _callbackMock = new() { CallBase = true }; - private static readonly Mock _exampleMock = new() { CallBase = true }; - private static readonly Mock _pathItemMock = new() { CallBase = true }; + private readonly OpenApiComponents _components; + private readonly Mock _schemaMock = new() { CallBase = true }; + private readonly Mock _requestBodyMock = new() { CallBase = true }; + private readonly Mock _responseMock = new() { CallBase = true }; + private readonly Mock _parameterMock = new() { CallBase = true }; + private readonly Mock _headerMock = new() { CallBase = true }; + private readonly Mock _securitySchemeMock = new() { CallBase = true }; + private readonly Mock _linkMock = new() { CallBase = true }; + private readonly Mock _callbackMock = new() { CallBase = true }; + private readonly Mock _exampleMock = new() { CallBase = true }; + private readonly Mock _pathItemMock = new() { CallBase = true }; public OpenApiComponentsSerializationTests() { + _components = OpenApiDocumentMock.CreateCompleteOpenApiDocument().Components; _components.Schemas["pet"] = _schemaMock.Object; _components.RequestBodies["pet"] = _requestBodyMock.Object; _components.Responses["200"] = _responseMock.Object; diff --git a/test/Microsoft.OpenApi.Tests/Mocks/OpenApiDocumentMock.cs b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiDocumentMock.cs index 961699b3a..84accabea 100644 --- a/test/Microsoft.OpenApi.Tests/Mocks/OpenApiDocumentMock.cs +++ b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiDocumentMock.cs @@ -13,7 +13,7 @@ public static class OpenApiDocumentMock { public static OpenApiDocument CreateCompleteOpenApiDocument() { - var doc = new OpenApiDocument + return new OpenApiDocument { Info = new OpenApiInfo { @@ -92,6 +92,13 @@ public static OpenApiDocument CreateCompleteOpenApiDocument() Value = JsonValue.Create("Fluffy") } }, + Content = new Dictionary + { + ["application/json"] = new OpenApiMediaType + { + Schema = new OpenApiSchemaReference("Pet") + } + } } ], Operations = new Dictionary @@ -179,6 +186,17 @@ public static OpenApiDocument CreateCompleteOpenApiDocument() Summary = "An example cat", Value = JsonValue.Create("Fluffy") } + }, + Content = new Dictionary + { + ["application/json"] = new OpenApiMediaType + { + Schema = new OpenApiSchema + { + Type = JsonSchemaType.Array, + Items = new OpenApiSchemaReference("Pet") + } + } } } }, @@ -233,8 +251,24 @@ public static OpenApiDocument CreateCompleteOpenApiDocument() } } } - } - } + }, + Security = + [ + new OpenApiSecurityRequirement + { + [new OpenApiSecuritySchemeReference("securitySchemeName1")] = [], + [new OpenApiSecuritySchemeReference("securitySchemeName2")] = + [ + "scope1", + "scope2" + ] + } + ], + Tags = new HashSet + { + new OpenApiTagReference("tagId1", new OpenApiDocument{ Tags = new HashSet() { new OpenApiTag{Name = "tagId1"}} }) + }, + } } } }, @@ -420,7 +454,6 @@ public static OpenApiDocument CreateCompleteOpenApiDocument() Url = new Uri("https://example.com/docs") } }; - return doc; } } diff --git a/test/Microsoft.OpenApi.Tests/Mocks/OpenApiDocumentSerializationTests.cs b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiDocumentSerializationTests.cs index 5f51ee23c..8d44d2623 100644 --- a/test/Microsoft.OpenApi.Tests/Mocks/OpenApiDocumentSerializationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiDocumentSerializationTests.cs @@ -9,17 +9,17 @@ namespace Microsoft.OpenApi.Tests.Mocks { public class OpenApiDocumentSerializationTests { - // test for PathItems, servers - private static readonly OpenApiDocument _document = OpenApiDocumentMock.CreateCompleteOpenApiDocument(); - private static readonly Mock _pathItemMock = new() { CallBase = true }; - private static readonly Mock _webhookPathItemMock = new() { CallBase = true }; - private static readonly Mock _serverMock = new() { CallBase = true }; - private static readonly Mock _tagMock = new() { CallBase = true }; - private static readonly Mock _securityMock = new() { CallBase = true }; - private static readonly Mock _componentsMock = new() { CallBase = true }; + private readonly OpenApiDocument _document; + private readonly Mock _pathItemMock = new() { CallBase = true }; + private readonly Mock _webhookPathItemMock = new() { CallBase = true }; + private readonly Mock _serverMock = new() { CallBase = true }; + private readonly Mock _tagMock = new() { CallBase = true }; + private readonly Mock _securityMock = new() { CallBase = true }; + private readonly Mock _componentsMock = new() { CallBase = true }; public OpenApiDocumentSerializationTests() { + _document = OpenApiDocumentMock.CreateCompleteOpenApiDocument(); _document.Paths["/pets"] = _pathItemMock.Object; _document.Webhooks["pets"] = _webhookPathItemMock.Object; _document.Servers[0] = _serverMock.Object; diff --git a/test/Microsoft.OpenApi.Tests/Mocks/OpenApiEncodingSerializationTests.cs b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiEncodingSerializationTests.cs index 7838df745..48e580d8d 100644 --- a/test/Microsoft.OpenApi.Tests/Mocks/OpenApiEncodingSerializationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiEncodingSerializationTests.cs @@ -9,12 +9,12 @@ namespace Microsoft.OpenApi.Tests.Mocks { public class OpenApiEncodingSerializationTests { - // test for header - private static readonly OpenApiEncoding _encoding = OpenApiDocumentMock.CreateCompleteOpenApiDocument().Paths["/pets"].Operations[HttpMethod.Get].Responses["200"].Content["application/json"].Encoding["x-rate-limit"]; - private static readonly Mock _headerMock = new() { CallBase = true }; + private readonly OpenApiEncoding _encoding; + private readonly Mock _headerMock = new() { CallBase = true }; public OpenApiEncodingSerializationTests() { + _encoding = OpenApiDocumentMock.CreateCompleteOpenApiDocument().Paths["/pets"].Operations[HttpMethod.Get].Responses["200"].Content["application/json"].Encoding["x-rate-limit"]; _encoding.Headers["x-encoding"] = _headerMock.Object; } diff --git a/test/Microsoft.OpenApi.Tests/Mocks/OpenApiHeaderSerializationTests.cs b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiHeaderSerializationTests.cs index f14721125..4d0fa5336 100644 --- a/test/Microsoft.OpenApi.Tests/Mocks/OpenApiHeaderSerializationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiHeaderSerializationTests.cs @@ -9,13 +9,14 @@ namespace Microsoft.OpenApi.Tests.Mocks { public class OpenApiHeaderSerializationTests { - private static readonly OpenApiHeader _header = (OpenApiHeader)OpenApiDocumentMock.CreateCompleteOpenApiDocument().Paths["/pets"].Operations[HttpMethod.Get].Responses["200"].Headers["x-rate-limit"]; - private static readonly Mock _schemaMock = new() { CallBase = true }; - private static readonly Mock _exampleMock = new() { CallBase = true }; - private static readonly Mock _mediaTypeMock = new() { CallBase = true }; + private readonly OpenApiHeader _header; + private readonly Mock _schemaMock = new() { CallBase = true }; + private readonly Mock _exampleMock = new() { CallBase = true }; + private readonly Mock _mediaTypeMock = new() { CallBase = true }; public OpenApiHeaderSerializationTests() { + _header = (OpenApiHeader)OpenApiDocumentMock.CreateCompleteOpenApiDocument().Paths["/pets"].Operations[HttpMethod.Get].Responses["200"].Headers["x-rate-limit"]; _header.Schema = _schemaMock.Object; _header.Examples["cat"] = _exampleMock.Object; _header.Content["application/json"] = _mediaTypeMock.Object; diff --git a/test/Microsoft.OpenApi.Tests/Mocks/OpenApiInfoSerializationTests.cs b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiInfoSerializationTests.cs index 686e68021..8f79f53c5 100644 --- a/test/Microsoft.OpenApi.Tests/Mocks/OpenApiInfoSerializationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiInfoSerializationTests.cs @@ -8,12 +8,13 @@ namespace Microsoft.OpenApi.Tests.Mocks { public class OpenApiInfoSerializationTests { - private static readonly OpenApiInfo _info = OpenApiDocumentMock.CreateCompleteOpenApiDocument().Info; - private static readonly Mock _contactMock = new() { CallBase = true }; - private static readonly Mock _licenseMock = new() { CallBase = true }; + private readonly OpenApiInfo _info; + private readonly Mock _contactMock = new() { CallBase = true }; + private readonly Mock _licenseMock = new() { CallBase = true }; public OpenApiInfoSerializationTests() { + _info = OpenApiDocumentMock.CreateCompleteOpenApiDocument().Info; _info.Contact = _contactMock.Object; _info.License = _licenseMock.Object; } diff --git a/test/Microsoft.OpenApi.Tests/Mocks/OpenApiMediaTypeSerializationTests.cs b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiMediaTypeSerializationTests.cs index b4f9b8d86..9504ae253 100644 --- a/test/Microsoft.OpenApi.Tests/Mocks/OpenApiMediaTypeSerializationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiMediaTypeSerializationTests.cs @@ -9,13 +9,14 @@ namespace Microsoft.OpenApi.Tests.Mocks { public class OpenApiMediaTypeSerializationTests { - private static readonly OpenApiMediaType _mediaType = OpenApiDocumentMock.CreateCompleteOpenApiDocument().Paths["/pets"].Operations[HttpMethod.Get].Responses["200"].Content["application/json"]; - private static readonly Mock _schemaMock = new() { CallBase = true }; - private static readonly Mock _encodingMock = new() { CallBase = true }; - private static readonly Mock _exampleMock = new() { CallBase = true }; + private readonly OpenApiMediaType _mediaType; + private readonly Mock _schemaMock = new() { CallBase = true }; + private readonly Mock _encodingMock = new() { CallBase = true }; + private readonly Mock _exampleMock = new() { CallBase = true }; public OpenApiMediaTypeSerializationTests() { + _mediaType = OpenApiDocumentMock.CreateCompleteOpenApiDocument().Paths["/pets"].Operations[HttpMethod.Get].Responses["200"].Content["application/json"]; _mediaType.Schema = _schemaMock.Object; _mediaType.Examples["cat"] = _exampleMock.Object; _mediaType.Examples["example"] = _exampleMock.Object; diff --git a/test/Microsoft.OpenApi.Tests/Mocks/OpenApiOperationSerializationTests.cs b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiOperationSerializationTests.cs index d267d1461..3106c2de2 100644 --- a/test/Microsoft.OpenApi.Tests/Mocks/OpenApiOperationSerializationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiOperationSerializationTests.cs @@ -11,25 +11,23 @@ namespace Microsoft.OpenApi.Tests.Mocks { public class OpenApiOperationSerializationTests { - private static readonly OpenApiOperation _operation = OpenApiDocumentMock.CreateCompleteOpenApiDocument().Paths["/pets"].Operations[HttpMethod.Get]; - - private static readonly Mock _callbackMock = new() { CallBase = true }; - private static readonly Mock _pathItemMock = new() { CallBase = true }; - private static readonly Mock _requestBodyMock = new() { CallBase = true }; - private static readonly Mock _responsesMock = new() { CallBase = true }; - private static readonly Mock _parameterMock = new() { CallBase = true }; - private static readonly Mock _securityRequirementMock = new() { CallBase = true }; - private static readonly Mock _tagMock = new() { CallBase = true }; + private readonly OpenApiOperation _operation; + private readonly Mock _callbackMock = new() { CallBase = true }; + private readonly Mock _pathItemMock = new() { CallBase = true }; + private readonly Mock _requestBodyMock = new() { CallBase = true }; + private readonly Mock _responsesMock = new() { CallBase = true }; + private readonly Mock _parameterMock = new() { CallBase = true }; + private readonly Mock _securityRequirementMock = new() { CallBase = true }; public OpenApiOperationSerializationTests() { + _operation = OpenApiDocumentMock.CreateCompleteOpenApiDocument().Paths["/pets"].Operations[HttpMethod.Get]; _operation.Callbacks["onData"] = _callbackMock.Object; _operation.Responses["200"] = _responsesMock.Object; _operation.RequestBody = _requestBodyMock.Object; _operation.Parameters[0] = _parameterMock.Object; _operation.Security[0] = _securityRequirementMock.Object; - _operation.Tags.ToList()[0] = _tagMock.Object; } [Fact] @@ -60,9 +58,6 @@ public void SerializeAsV31_DoesNotCallV3OrV2Serialization() _securityRequirementMock.Verify(c => c.SerializeAsV3(It.IsAny()), Times.Never, "V3 method should not be called"); _securityRequirementMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); - - _tagMock.Verify(c => c.SerializeAsV3(It.IsAny()), Times.Never, "V3 method should not be called"); - _tagMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); } [Fact] @@ -93,9 +88,6 @@ public void SerializeAsV3_DoesNotCallV31OrV2Serialization() _securityRequirementMock.Verify(c => c.SerializeAsV31(It.IsAny()), Times.Never, "V31 method should not be called"); _securityRequirementMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); - - _tagMock.Verify(c => c.SerializeAsV31(It.IsAny()), Times.Never, "V31 method should not be called"); - _tagMock.Verify(c => c.SerializeAsV2(It.IsAny()), Times.Never, "V2 method should not be called"); } } } diff --git a/test/Microsoft.OpenApi.Tests/Mocks/OpenApiParameterSerializationTests.cs b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiParameterSerializationTests.cs index 76b32354f..b6bb61bba 100644 --- a/test/Microsoft.OpenApi.Tests/Mocks/OpenApiParameterSerializationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiParameterSerializationTests.cs @@ -8,13 +8,14 @@ namespace Microsoft.OpenApi.Tests.Mocks { public class OpenApiParameterSerializationTests { - private static readonly OpenApiParameter _parameter = (OpenApiParameter)OpenApiDocumentMock.CreateCompleteOpenApiDocument().Paths["/pets"].Parameters[0]; - private static readonly Mock _schemaMock = new() { CallBase = true }; - private static readonly Mock _contentMock = new() { CallBase = true }; - private static readonly Mock _exampleMock = new() { CallBase = true }; + private readonly OpenApiParameter _parameter; + private readonly Mock _schemaMock = new() { CallBase = true }; + private readonly Mock _contentMock = new() { CallBase = true }; + private readonly Mock _exampleMock = new() { CallBase = true }; public OpenApiParameterSerializationTests() { + _parameter = (OpenApiParameter)OpenApiDocumentMock.CreateCompleteOpenApiDocument().Paths["/pets"].Parameters[0]; _parameter.Schema = _schemaMock.Object; _parameter.Content["application/json"] = _contentMock.Object; _parameter.Examples["example"] = _exampleMock.Object; diff --git a/test/Microsoft.OpenApi.Tests/Mocks/OpenApiPathItemSerializationTests.cs b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiPathItemSerializationTests.cs index 3b1339172..12f63dcf6 100644 --- a/test/Microsoft.OpenApi.Tests/Mocks/OpenApiPathItemSerializationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiPathItemSerializationTests.cs @@ -10,13 +10,14 @@ namespace Microsoft.OpenApi.Tests.Mocks { public class OpenApiPathItemSerializationTests { - private static readonly IOpenApiPathItem _pathItem = OpenApiDocumentMock.CreateCompleteOpenApiDocument().Paths["/pets"]; - private static readonly Mock _operationMock = new() { CallBase = true }; - private static readonly Mock _serverMock = new() { CallBase = true }; - private static readonly Mock _parameterMock = new() { CallBase = true }; + private readonly IOpenApiPathItem _pathItem; + private readonly Mock _operationMock = new() { CallBase = true }; + private readonly Mock _serverMock = new() { CallBase = true }; + private readonly Mock _parameterMock = new() { CallBase = true }; public OpenApiPathItemSerializationTests() { + _pathItem = OpenApiDocumentMock.CreateCompleteOpenApiDocument().Paths["/pets"]; _pathItem.Operations[HttpMethod.Get] = _operationMock.Object; _pathItem.Servers[0] = _serverMock.Object ; _pathItem.Parameters[0] = _parameterMock.Object; diff --git a/test/Microsoft.OpenApi.Tests/Mocks/OpenApiRequestBodySerializationTests.cs b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiRequestBodySerializationTests.cs index 79cff9050..b344930c7 100644 --- a/test/Microsoft.OpenApi.Tests/Mocks/OpenApiRequestBodySerializationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiRequestBodySerializationTests.cs @@ -10,11 +10,12 @@ namespace Microsoft.OpenApi.Tests.Mocks { public class OpenApiRequestBodySerializationTests { - private static readonly IOpenApiRequestBody _requestBody = OpenApiDocumentMock.CreateCompleteOpenApiDocument().Paths["/pets"].Operations[HttpMethod.Get].RequestBody; - private static readonly Mock _mediaTypeMock = new() { CallBase = true }; + private readonly IOpenApiRequestBody _requestBody; + private readonly Mock _mediaTypeMock = new() { CallBase = true }; public OpenApiRequestBodySerializationTests() { + _requestBody = OpenApiDocumentMock.CreateCompleteOpenApiDocument().Paths["/pets"].Operations[HttpMethod.Get].RequestBody; _requestBody.Content["application/json"] = _mediaTypeMock.Object; } diff --git a/test/Microsoft.OpenApi.Tests/Mocks/OpenApiResponseSerializationTests.cs b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiResponseSerializationTests.cs index 29df27f33..fb6321d52 100644 --- a/test/Microsoft.OpenApi.Tests/Mocks/OpenApiResponseSerializationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiResponseSerializationTests.cs @@ -10,13 +10,14 @@ namespace Microsoft.OpenApi.Tests.Mocks { public class OpenApiResponseSerializationTests { - private static readonly IOpenApiResponse _response = OpenApiDocumentMock.CreateCompleteOpenApiDocument().Paths["/pets"].Operations[HttpMethod.Get].Responses["200"]; - private static readonly Mock _headerMock = new() { CallBase = true }; - private static readonly Mock _mediaTypeMock = new() { CallBase = true }; - private static readonly Mock _linkMock = new() { CallBase = true }; + private readonly IOpenApiResponse _response; + private readonly Mock _headerMock = new() { CallBase = true }; + private readonly Mock _mediaTypeMock = new() { CallBase = true }; + private readonly Mock _linkMock = new() { CallBase = true }; public OpenApiResponseSerializationTests() { + _response = OpenApiDocumentMock.CreateCompleteOpenApiDocument().Paths["/pets"].Operations[HttpMethod.Get].Responses["200"]; _response.Headers["x-rate-limit"] = _headerMock.Object; _response.Content["application/json"] = _mediaTypeMock.Object; _response.Links["UserRepositories"] = _linkMock.Object; diff --git a/test/Microsoft.OpenApi.Tests/Mocks/OpenApiSchemaSerializationTests.cs b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiSchemaSerializationTests.cs index 2cc0eca8b..2f2fba9a2 100644 --- a/test/Microsoft.OpenApi.Tests/Mocks/OpenApiSchemaSerializationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiSchemaSerializationTests.cs @@ -9,11 +9,12 @@ namespace Microsoft.OpenApi.Tests.Mocks { public class OpenApiSchemaSerializationTests { - private static readonly OpenApiSchema _schema = (OpenApiSchema)OpenApiDocumentMock.CreateCompleteOpenApiDocument().Paths["/pets"].Operations[HttpMethod.Get].RequestBody.Content["application/xml"].Schema; - private static readonly Mock _xmlMock = new() { CallBase = true }; + private readonly OpenApiSchema _schema; + private readonly Mock _xmlMock = new() { CallBase = true }; public OpenApiSchemaSerializationTests() { + _schema = (OpenApiSchema)OpenApiDocumentMock.CreateCompleteOpenApiDocument().Paths["/pets"].Operations[HttpMethod.Get].Responses["200"].Content["application/json"].Schema; _schema.Xml = _xmlMock.Object; } diff --git a/test/Microsoft.OpenApi.Tests/Mocks/OpenApiSecuritySchemeSerializationTests.cs b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiSecuritySchemeSerializationTests.cs index aced889b0..cfabf4957 100644 --- a/test/Microsoft.OpenApi.Tests/Mocks/OpenApiSecuritySchemeSerializationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiSecuritySchemeSerializationTests.cs @@ -8,11 +8,12 @@ namespace Microsoft.OpenApi.Tests.Mocks { public class OpenApiSecuritySchemeSerializationTests { - private static readonly OpenApiSecurityScheme _securityScheme = (OpenApiSecurityScheme)OpenApiDocumentMock.CreateCompleteOpenApiDocument().Components.SecuritySchemes["api_key"]; - private static readonly Mock _authFlowMock = new() { CallBase = true }; + private readonly OpenApiSecurityScheme _securityScheme; + private readonly Mock _authFlowMock = new() { CallBase = true }; public OpenApiSecuritySchemeSerializationTests() { + _securityScheme = (OpenApiSecurityScheme)OpenApiDocumentMock.CreateCompleteOpenApiDocument().Components.SecuritySchemes["api_key"]; _securityScheme.Flows = _authFlowMock.Object; } diff --git a/test/Microsoft.OpenApi.Tests/Mocks/OpenApiTagsSerialization.cs b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiTagsSerialization.cs index 1d0997f53..91ee20c8a 100644 --- a/test/Microsoft.OpenApi.Tests/Mocks/OpenApiTagsSerialization.cs +++ b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiTagsSerialization.cs @@ -9,11 +9,12 @@ namespace Microsoft.OpenApi.Tests.Mocks { public class OpenApiTagsSerialization { - private static readonly OpenApiTag _tag = OpenApiDocumentMock.CreateCompleteOpenApiDocument().Tags.ToList()[0]; - private static readonly Mock _externalDocsMock = new() { CallBase = true }; + private readonly OpenApiTag _tag; + private readonly Mock _externalDocsMock = new() { CallBase = true }; public OpenApiTagsSerialization() { + _tag = OpenApiDocumentMock.CreateCompleteOpenApiDocument().Tags.ToList()[0]; _tag.ExternalDocs = _externalDocsMock.Object; } diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index 1e3c88ec0..fb2bab0e4 100644 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -495,9 +495,9 @@ namespace Microsoft.OpenApi.Models public System.Collections.Generic.Dictionary? PathItems { get; set; } public void AddPathItem(Microsoft.OpenApi.Expressions.RuntimeExpression expression, Microsoft.OpenApi.Models.Interfaces.IOpenApiPathItem pathItem) { } public Microsoft.OpenApi.Models.Interfaces.IOpenApiCallback CreateShallowCopy() { } - public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } - public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } - public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } } public class OpenApiComponents : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { @@ -514,9 +514,9 @@ namespace Microsoft.OpenApi.Models public System.Collections.Generic.Dictionary? Responses { get; set; } public System.Collections.Generic.Dictionary? Schemas { get; set; } public System.Collections.Generic.Dictionary? SecuritySchemes { get; set; } - public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } - public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } - public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } } public static class OpenApiConstants { @@ -684,9 +684,9 @@ namespace Microsoft.OpenApi.Models public System.Collections.Generic.Dictionary? Extensions { get; set; } public string? Name { get; set; } public System.Uri? Url { get; set; } - public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } - public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } - public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } } public class OpenApiDiscriminator : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { @@ -739,9 +739,9 @@ namespace Microsoft.OpenApi.Models public System.Collections.Generic.Dictionary? Extensions { get; set; } public System.Collections.Generic.Dictionary? Headers { get; set; } public Microsoft.OpenApi.Models.ParameterStyle? Style { get; set; } - public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } - public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } - public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } } public class OpenApiError { @@ -761,9 +761,9 @@ namespace Microsoft.OpenApi.Models public string? Summary { get; set; } public System.Text.Json.Nodes.JsonNode? Value { get; set; } public Microsoft.OpenApi.Models.Interfaces.IOpenApiExample CreateShallowCopy() { } - public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } - public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } - public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } } public abstract class OpenApiExtensibleDictionary : System.Collections.Generic.Dictionary, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable where T : Microsoft.OpenApi.Interfaces.IOpenApiSerializable @@ -782,9 +782,9 @@ namespace Microsoft.OpenApi.Models public string? Description { get; set; } public System.Collections.Generic.Dictionary? Extensions { get; set; } public System.Uri? Url { get; set; } - public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } - public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } - public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } } public class OpenApiHeader : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiHeader { @@ -802,9 +802,9 @@ namespace Microsoft.OpenApi.Models public Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema? Schema { get; set; } public Microsoft.OpenApi.Models.ParameterStyle? Style { get; set; } public Microsoft.OpenApi.Models.Interfaces.IOpenApiHeader CreateShallowCopy() { } - public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } - public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } - public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } } public class OpenApiInfo : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { @@ -830,9 +830,9 @@ namespace Microsoft.OpenApi.Models public string? Identifier { get; set; } public string? Name { get; set; } public System.Uri? Url { get; set; } - public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } - public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } - public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } } public class OpenApiLink : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiLink { @@ -845,9 +845,9 @@ namespace Microsoft.OpenApi.Models public Microsoft.OpenApi.Models.RuntimeExpressionAnyWrapper? RequestBody { get; set; } public Microsoft.OpenApi.Models.OpenApiServer? Server { get; set; } public Microsoft.OpenApi.Models.Interfaces.IOpenApiLink CreateShallowCopy() { } - public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } - public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } - public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } } public class OpenApiMediaType : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { @@ -858,9 +858,9 @@ namespace Microsoft.OpenApi.Models public System.Collections.Generic.Dictionary? Examples { get; set; } public System.Collections.Generic.Dictionary? Extensions { get; set; } public Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema? Schema { get; set; } - public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } - public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } - public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } } public class OpenApiOAuthFlow : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { @@ -884,9 +884,9 @@ namespace Microsoft.OpenApi.Models public System.Collections.Generic.Dictionary? Extensions { get; set; } public Microsoft.OpenApi.Models.OpenApiOAuthFlow? Implicit { get; set; } public Microsoft.OpenApi.Models.OpenApiOAuthFlow? Password { get; set; } - public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } - public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } - public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } } public class OpenApiOperation : Microsoft.OpenApi.Interfaces.IMetadataContainer, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { @@ -907,9 +907,9 @@ namespace Microsoft.OpenApi.Models public System.Collections.Generic.List? Servers { get; set; } public string? Summary { get; set; } public System.Collections.Generic.HashSet? Tags { get; set; } - public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } - public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } - public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } } public class OpenApiParameter : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiParameter { @@ -929,9 +929,9 @@ namespace Microsoft.OpenApi.Models public Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema? Schema { get; set; } public Microsoft.OpenApi.Models.ParameterStyle? Style { get; set; } public Microsoft.OpenApi.Models.Interfaces.IOpenApiParameter CreateShallowCopy() { } - public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } - public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } - public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } } public class OpenApiPathItem : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiPathItem, Microsoft.OpenApi.Models.Interfaces.IOpenApiSummarizedElement { @@ -944,9 +944,9 @@ namespace Microsoft.OpenApi.Models public string? Summary { get; set; } public void AddOperation(System.Net.Http.HttpMethod operationType, Microsoft.OpenApi.Models.OpenApiOperation operation) { } public Microsoft.OpenApi.Models.Interfaces.IOpenApiPathItem CreateShallowCopy() { } - public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } - public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } - public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } } public class OpenApiPaths : Microsoft.OpenApi.Models.OpenApiExtensibleDictionary { @@ -982,9 +982,9 @@ namespace Microsoft.OpenApi.Models public Microsoft.OpenApi.Models.Interfaces.IOpenApiParameter ConvertToBodyParameter(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public System.Collections.Generic.IEnumerable ConvertToFormDataParameters(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public Microsoft.OpenApi.Models.Interfaces.IOpenApiRequestBody CreateShallowCopy() { } - public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } - public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } - public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } } public class OpenApiResponse : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiResponse { @@ -995,9 +995,9 @@ namespace Microsoft.OpenApi.Models public System.Collections.Generic.Dictionary? Headers { get; set; } public System.Collections.Generic.Dictionary? Links { get; set; } public Microsoft.OpenApi.Models.Interfaces.IOpenApiResponse CreateShallowCopy() { } - public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } - public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } - public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } } public class OpenApiResponses : Microsoft.OpenApi.Models.OpenApiExtensibleDictionary { @@ -1058,16 +1058,16 @@ namespace Microsoft.OpenApi.Models public bool WriteOnly { get; set; } public Microsoft.OpenApi.Models.OpenApiXml? Xml { get; set; } public Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema CreateShallowCopy() { } - public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } - public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } - public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } } public class OpenApiSecurityRequirement : System.Collections.Generic.Dictionary>, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { public OpenApiSecurityRequirement() { } - public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } - public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } - public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } } public class OpenApiSecurityScheme : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiSecurityScheme { @@ -1082,9 +1082,9 @@ namespace Microsoft.OpenApi.Models public string? Scheme { get; set; } public Microsoft.OpenApi.Models.SecuritySchemeType? Type { get; set; } public Microsoft.OpenApi.Models.Interfaces.IOpenApiSecurityScheme CreateShallowCopy() { } - public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } - public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } - public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } } public class OpenApiServer : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { @@ -1094,9 +1094,9 @@ namespace Microsoft.OpenApi.Models public System.Collections.Generic.Dictionary? Extensions { get; set; } public string? Url { get; set; } public System.Collections.Generic.Dictionary? Variables { get; set; } - public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } - public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } - public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } } public class OpenApiServerVariable : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { @@ -1118,9 +1118,9 @@ namespace Microsoft.OpenApi.Models public Microsoft.OpenApi.Models.OpenApiExternalDocs? ExternalDocs { get; set; } public string? Name { get; set; } public Microsoft.OpenApi.Models.Interfaces.IOpenApiTag CreateShallowCopy() { } - public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } - public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } - public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } } public class OpenApiXml : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { @@ -1132,9 +1132,9 @@ namespace Microsoft.OpenApi.Models public System.Uri? Namespace { get; set; } public string? Prefix { get; set; } public bool Wrapped { get; set; } - public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } - public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } - public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } + public virtual void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } } public enum ParameterLocation { From 186b18297febb5c9feb2f232ecd5d820285b9347 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Mon, 28 Apr 2025 17:44:55 +0300 Subject: [PATCH 113/984] chore: clean up --- docs/upgrade-guide-2.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/upgrade-guide-2.md b/docs/upgrade-guide-2.md index a54cc280c..84e6ada8d 100644 --- a/docs/upgrade-guide-2.md +++ b/docs/upgrade-guide-2.md @@ -602,7 +602,7 @@ All the IEffective and GetEffective methods in the models have been removed as w ### Shallow Copy in place of copy constructors -Copy constructors for referenceable components have been made internal, a new *CreateShallowCopy()* method has been exposed on these models to facilitate deep copying. +Copy constructors for referenceable components have been made internal, a new *CreateShallowCopy()* method has been exposed on these models to facilitate cloning. **Example:** ```csharp From 5c40c174fbb700b487691b0e491d92ed3a7728a5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 28 Apr 2025 22:18:22 +0000 Subject: [PATCH 114/984] chore(deps): bump Verify.Xunit from 29.3.0 to 29.3.1 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 29.3.0 to 29.3.1. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/29.3.0...29.3.1) --- updated-dependencies: - dependency-name: Verify.Xunit dependency-version: 29.3.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index b5406cd9f..d33b26d3e 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -15,7 +15,7 @@ - + From ec9a3f5afd80cacab1b01117b8fd90371f237987 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 29 Apr 2025 21:57:42 +0000 Subject: [PATCH 115/984] chore(deps): bump Verify.Xunit from 29.3.1 to 29.4.0 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 29.3.1 to 29.4.0. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/29.3.1...29.4.0) --- updated-dependencies: - dependency-name: Verify.Xunit dependency-version: 29.4.0 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 d33b26d3e..24e8a902c 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -15,7 +15,7 @@ - + From 3f8b2b99c07bd3c58825728c2dd2ffed91d88fbe Mon Sep 17 00:00:00 2001 From: Martin Costello Date: Wed, 30 Apr 2025 09:26:34 +0100 Subject: [PATCH 116/984] fix: Fix typo in error message (#2345) Fix typo in error message introduced by #2325. --- src/Microsoft.OpenApi/Models/OpenApiOperation.cs | 2 +- test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi/Models/OpenApiOperation.cs b/src/Microsoft.OpenApi/Models/OpenApiOperation.cs index 3024f230a..b446ccbd4 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiOperation.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiOperation.cs @@ -365,7 +365,7 @@ public void SerializeAsV2(IOpenApiWriter writer) { if (tag.Target is null) { - throw new OpenApiException($"The OpenAPI tag reference '{tag.Reference.Id}' does reference a valid tag."); + throw new OpenApiException($"The OpenAPI tag reference '{tag.Reference.Id}' does not reference a valid tag."); } } } diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs index 3c465f576..351365065 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs @@ -887,7 +887,7 @@ public async Task SerializeAsJsonAsyncThrowsIfTagReferenceIsUnresolved(OpenApiSp }; var exception = await Assert.ThrowsAsync(() => operation.SerializeAsJsonAsync(version)); - Assert.Equal("The OpenAPI tag reference 'two' does reference a valid tag.", exception.Message); + Assert.Equal("The OpenAPI tag reference 'two' does not reference a valid tag.", exception.Message); } } } From 3575e809124cb8c839f2451ca27c224e3fdc9745 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 30 Apr 2025 21:34:11 +0000 Subject: [PATCH 117/984] chore(deps): bump Verify.Xunit from 29.4.0 to 29.5.0 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 29.4.0 to 29.5.0. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/29.4.0...29.5.0) --- updated-dependencies: - dependency-name: Verify.Xunit dependency-version: 29.5.0 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 24e8a902c..7f83aac92 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -15,7 +15,7 @@ - + From 9258356fd308b54bf66075f98db10053ebf5f44f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 May 2025 22:00:13 +0000 Subject: [PATCH 118/984] chore(deps): bump xunit.runner.visualstudio from 3.0.2 to 3.1.0 Bumps [xunit.runner.visualstudio](https://github.com/xunit/visualstudio.xunit) from 3.0.2 to 3.1.0. - [Release notes](https://github.com/xunit/visualstudio.xunit/releases) - [Commits](https://github.com/xunit/visualstudio.xunit/compare/3.0.2...3.1.0) --- updated-dependencies: - dependency-name: xunit.runner.visualstudio dependency-version: 3.1.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .../Microsoft.OpenApi.Hidi.Tests.csproj | 4 ++-- .../Microsoft.OpenApi.Readers.Tests.csproj | 4 ++-- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj index 47d67fc5b..ec82664d2 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj +++ b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj @@ -1,4 +1,4 @@ - + net8.0 @@ -15,7 +15,7 @@ - + diff --git a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj index 24ca03155..1b3fa4307 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj +++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj @@ -1,4 +1,4 @@ - + net8.0 false @@ -21,7 +21,7 @@ - + diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 7f83aac92..4361bd819 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -17,7 +17,7 @@ - + From 28ffdac5eb0811543643d7bc07d23280b892503b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 6 May 2025 07:10:53 +0000 Subject: [PATCH 119/984] chore(deps): bump Verify.Xunit from 29.5.0 to 30.0.0 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 29.5.0 to 30.0.0. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/29.5.0...30.0.0) --- updated-dependencies: - dependency-name: Verify.Xunit dependency-version: 30.0.0 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 4361bd819..69ebd98a4 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -15,7 +15,7 @@ - + From 5c40b3303fe8de8e53aabd0fd85771e305f2958e Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Tue, 6 May 2025 10:21:51 +0300 Subject: [PATCH 120/984] chore: clean up v1 example --- docs/upgrade-guide-2.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/upgrade-guide-2.md b/docs/upgrade-guide-2.md index 006486d81..ebe3acb5b 100644 --- a/docs/upgrade-guide-2.md +++ b/docs/upgrade-guide-2.md @@ -203,7 +203,7 @@ var openApiObject = new OpenApiObject } }; var parameter = new OpenApiParameter(); -parameter.Extensions.Add("x-foo", new JsonNodeExtension(openApiObject)); +parameter.Extensions.Add("x-foo", openApiObject); ``` From 65c87897c914f6f79c57f6091fbddc76b498e4c9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 May 2025 21:17:02 +0000 Subject: [PATCH 121/984] chore(deps): bump dependabot/fetch-metadata from 2.3.0 to 2.4.0 Bumps [dependabot/fetch-metadata](https://github.com/dependabot/fetch-metadata) from 2.3.0 to 2.4.0. - [Release notes](https://github.com/dependabot/fetch-metadata/releases) - [Commits](https://github.com/dependabot/fetch-metadata/compare/v2.3.0...v2.4.0) --- updated-dependencies: - dependency-name: dependabot/fetch-metadata dependency-version: 2.4.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/auto-merge-dependabot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/auto-merge-dependabot.yml b/.github/workflows/auto-merge-dependabot.yml index df4b487a7..d454cd186 100644 --- a/.github/workflows/auto-merge-dependabot.yml +++ b/.github/workflows/auto-merge-dependabot.yml @@ -19,7 +19,7 @@ jobs: steps: - name: Dependabot metadata id: metadata - uses: dependabot/fetch-metadata@v2.3.0 + uses: dependabot/fetch-metadata@v2.4.0 with: github-token: "${{ secrets.GITHUB_TOKEN }}" From 69611df8485b5b5985a7f67dbeecb34011e0fa34 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 13 May 2025 10:31:15 +0300 Subject: [PATCH 122/984] Update docs/upgrade-guide-2.md Co-authored-by: Vincent Biret --- docs/upgrade-guide-2.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/upgrade-guide-2.md b/docs/upgrade-guide-2.md index 84e6ada8d..d6121a624 100644 --- a/docs/upgrade-guide-2.md +++ b/docs/upgrade-guide-2.md @@ -632,7 +632,7 @@ Discriminator = new() } //v2.0 -Discriminator = new()public string? ExclusiveMaximum +Discriminator = new() { PropertyName = "@odata.type", Mapping = new Dictionary { From 962e0e436f96b1b68613013d75307dc1f92ce15c Mon Sep 17 00:00:00 2001 From: "Paul Rijneveld @ Mendix" Date: Tue, 13 May 2025 09:35:10 +0200 Subject: [PATCH 123/984] fix: handle deserializing and writing empty security requirements #1426 (#2323) * fix!: handle deserializing and writing empty security requirements #1426 make distinction between empty security requirements and no security requirements on an operation. empty security requirements are read as an empty list, no security requirements are read as null for OpenAPI v2/v3/v3.1. This is a breaking change, previously both cases were read as an empty list. also includes a change to OpenApiOperation.SerializeInternal so it can serialize these two cases separately. this required a new method OpenApiWriterExtensions.WriteOptionalOrEmptyCollection. includes unit tests, change to PublicApi.approved.txt to include the new method, and I removed a couple of unused usings and a typo in test name `SerializeDocWithSecuritySchemeWithInlineReferencesWorks`. * Review: make security property tests more explicit * Review: remove unneeded list creation from list --- .../Models/OpenApiOperation.cs | 4 +- .../Reader/V2/OpenApiOperationDeserializer.cs | 6 +- .../Reader/V3/OpenApiOperationDeserializer.cs | 9 ++- .../V31/OpenApiOperationDeserializer.cs | 8 +- .../Writers/OpenApiWriterExtensions.cs | 20 +++++ .../Microsoft.OpenApi.Tests.csproj | 8 ++ .../Models/OpenApiDocumentTests.cs | 73 ++++++++++++++++++- .../docWithEmptyOperationSecurity.yaml | 20 +++++ .../Samples/docWithoutOperationSecurity.yaml | 19 +++++ .../PublicApi/PublicApi.approved.txt | 1 + 10 files changed, 160 insertions(+), 8 deletions(-) create mode 100644 test/Microsoft.OpenApi.Tests/Models/Samples/docWithEmptyOperationSecurity.yaml create mode 100644 test/Microsoft.OpenApi.Tests/Models/Samples/docWithoutOperationSecurity.yaml diff --git a/src/Microsoft.OpenApi/Models/OpenApiOperation.cs b/src/Microsoft.OpenApi/Models/OpenApiOperation.cs index b446ccbd4..561e966b5 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiOperation.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiOperation.cs @@ -214,8 +214,8 @@ private void SerializeInternal(IOpenApiWriter writer, OpenApiSpecVersion version writer.WriteProperty(OpenApiConstants.Deprecated, Deprecated, false); // security - writer.WriteOptionalCollection(OpenApiConstants.Security, Security, callback); - + writer.WriteOptionalOrEmptyCollection(OpenApiConstants.Security, Security, callback); + // servers writer.WriteOptionalCollection(OpenApiConstants.Servers, Servers, callback); diff --git a/src/Microsoft.OpenApi/Reader/V2/OpenApiOperationDeserializer.cs b/src/Microsoft.OpenApi/Reader/V2/OpenApiOperationDeserializer.cs index ebea2bc40..c0358cfd6 100644 --- a/src/Microsoft.OpenApi/Reader/V2/OpenApiOperationDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V2/OpenApiOperationDeserializer.cs @@ -9,6 +9,7 @@ using Microsoft.OpenApi.Models.References; using Microsoft.OpenApi.Models.Interfaces; using System; +using System.Text.Json.Nodes; namespace Microsoft.OpenApi.Reader.V2 { @@ -94,7 +95,10 @@ internal static partial class OpenApiV2Deserializer }, { "security", - (o, n, t) => o.Security = n.CreateList(LoadSecurityRequirement, t) + (o, n, t) => { if (n.JsonNode is JsonArray) + { + o.Security = n.CreateList(LoadSecurityRequirement, t); + } } }, }; diff --git a/src/Microsoft.OpenApi/Reader/V3/OpenApiOperationDeserializer.cs b/src/Microsoft.OpenApi/Reader/V3/OpenApiOperationDeserializer.cs index eb971da7c..8a0e19336 100644 --- a/src/Microsoft.OpenApi/Reader/V3/OpenApiOperationDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V3/OpenApiOperationDeserializer.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Text.Json.Nodes; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.References; @@ -83,7 +84,13 @@ internal static partial class OpenApiV3Deserializer }, { "security", - (o, n, t) => o.Security = n.CreateList(LoadSecurityRequirement, t) + (o, n, t) => + { + if (n.JsonNode is JsonArray) + { + o.Security = n.CreateList(LoadSecurityRequirement, t); + } + } }, { "servers", diff --git a/src/Microsoft.OpenApi/Reader/V31/OpenApiOperationDeserializer.cs b/src/Microsoft.OpenApi/Reader/V31/OpenApiOperationDeserializer.cs index abf35545b..d04e91750 100644 --- a/src/Microsoft.OpenApi/Reader/V31/OpenApiOperationDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V31/OpenApiOperationDeserializer.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Text.Json.Nodes; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.References; @@ -96,8 +97,11 @@ internal static partial class OpenApiV31Deserializer }, { "security", (o, n, t) => - { - o.Security = n.CreateList(LoadSecurityRequirement, t); + { + if (n.JsonNode is JsonArray) + { + o.Security = n.CreateList(LoadSecurityRequirement, t); + } } }, { diff --git a/src/Microsoft.OpenApi/Writers/OpenApiWriterExtensions.cs b/src/Microsoft.OpenApi/Writers/OpenApiWriterExtensions.cs index 31f60d0fd..c799171c5 100644 --- a/src/Microsoft.OpenApi/Writers/OpenApiWriterExtensions.cs +++ b/src/Microsoft.OpenApi/Writers/OpenApiWriterExtensions.cs @@ -217,6 +217,26 @@ public static void WriteOptionalCollection( writer.WriteCollectionInternal(name, elements, action); } } + + /// + /// Write the optional or empty Open API object/element collection. + /// + /// The Open API element type. + /// The Open API writer. + /// The property name. + /// The collection values. + /// The collection element writer action. + public static void WriteOptionalOrEmptyCollection( + this IOpenApiWriter writer, + string name, + IEnumerable? elements, + Action action) + { + if (elements != null) + { + writer.WriteCollectionInternal(name, elements, action); + } + } /// /// Write the required Open API object/element collection. diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 69ebd98a4..bbf1b8742 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -56,5 +56,13 @@ + + + PreserveNewest + + + + PreserveNewest + \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs index bbeeaf10f..993de7a2d 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs @@ -12,7 +12,6 @@ using Microsoft.OpenApi.Models.Interfaces; using Microsoft.OpenApi.Models.References; using Microsoft.OpenApi.Writers; -using Microsoft.VisualBasic; using VerifyXunit; using Xunit; @@ -2177,7 +2176,7 @@ public void SerializeAsThrowsIfVersionIsNotSupported() } [Fact] - public async Task SerializeDocWithSecuritySchemeWithInlineRefererencesWorks() + public async Task SerializeDocWithSecuritySchemeWithInlineReferencesWorks() { var expected = @"openapi: 3.0.4 info: @@ -2218,5 +2217,75 @@ public async Task SerializeDocWithSecuritySchemeWithInlineRefererencesWorks() var actual = stringWriter.ToString(); Assert.Equal(expected.MakeLineBreaksEnvironmentNeutral(), actual.MakeLineBreaksEnvironmentNeutral()); } + + [Fact] + public async Task SerializeDocWithoutOperationSecurityWorks() + { + var expected = """ + openapi: 3.0.4 + info: + title: Repair Service + version: 1.0.0 + servers: + - url: https://pluginrentu.azurewebsites.net/api + paths: + /repairs: + get: + summary: List all repairs + description: Returns a list of repairs with their details and images + operationId: listRepairs + responses: + '200': + description: A list of repairs + content: + application/json: + schema: + type: object + """; + + var doc = (await OpenApiDocument.LoadAsync("Models/Samples/docWithoutOperationSecurity.yaml", SettingsFixture.ReaderSettings)).Document; + var stringWriter = new StringWriter(); + doc!.SerializeAsV3(new OpenApiYamlWriter(stringWriter, new OpenApiWriterSettings { InlineLocalReferences = true })); + var actual = stringWriter.ToString(); + Assert.Equal(expected.MakeLineBreaksEnvironmentNeutral(), actual.MakeLineBreaksEnvironmentNeutral()); + var actualOperation = doc.Paths["/repairs"]!.Operations![HttpMethod.Get]; + Assert.Null(actualOperation.Security); + } + + [Fact] + public async Task SerializeDocWithEmptyOperationSecurityWorks() + { + var expected = """ + openapi: 3.0.4 + info: + title: Repair Service + version: 1.0.0 + servers: + - url: https://pluginrentu.azurewebsites.net/api + paths: + /repairs: + get: + summary: List all repairs + description: Returns a list of repairs with their details and images + operationId: listRepairs + responses: + '200': + description: A list of repairs + content: + application/json: + schema: + type: object + security: [ ] + """; + + var doc = (await OpenApiDocument.LoadAsync("Models/Samples/docWithEmptyOperationSecurity.yaml", SettingsFixture.ReaderSettings)).Document; + var stringWriter = new StringWriter(); + doc!.SerializeAsV3(new OpenApiYamlWriter(stringWriter, new OpenApiWriterSettings { InlineLocalReferences = true })); + var actual = stringWriter.ToString(); + Assert.Equal(expected.MakeLineBreaksEnvironmentNeutral(), actual.MakeLineBreaksEnvironmentNeutral()); + var actualOperation = doc.Paths["/repairs"]!.Operations![HttpMethod.Get]; + Assert.NotNull(actualOperation.Security); + Assert.Empty(actualOperation.Security); + } } } diff --git a/test/Microsoft.OpenApi.Tests/Models/Samples/docWithEmptyOperationSecurity.yaml b/test/Microsoft.OpenApi.Tests/Models/Samples/docWithEmptyOperationSecurity.yaml new file mode 100644 index 000000000..1f397fedf --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/Samples/docWithEmptyOperationSecurity.yaml @@ -0,0 +1,20 @@ +openapi: 3.0.0 +info: + title: Repair Service + version: 1.0.0 +servers: + - url: https://pluginrentu.azurewebsites.net/api +paths: + /repairs: + get: + operationId: listRepairs + summary: List all repairs + description: Returns a list of repairs with their details and images + responses: + '200': + description: A list of repairs + content: + application/json: + schema: + type: object + security: [] \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/Samples/docWithoutOperationSecurity.yaml b/test/Microsoft.OpenApi.Tests/Models/Samples/docWithoutOperationSecurity.yaml new file mode 100644 index 000000000..edaf2f1f7 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/Samples/docWithoutOperationSecurity.yaml @@ -0,0 +1,19 @@ +openapi: 3.0.0 +info: + title: Repair Service + version: 1.0.0 +servers: + - url: https://pluginrentu.azurewebsites.net/api +paths: + /repairs: + get: + operationId: listRepairs + summary: List all repairs + description: Returns a list of repairs with their details and images + responses: + '200': + description: A list of repairs + content: + application/json: + schema: + type: object \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index 080f648c7..0eef70848 100644 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -1967,6 +1967,7 @@ namespace Microsoft.OpenApi.Writers public static void WriteOptionalMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.Dictionary? elements, System.Action action) where T : Microsoft.OpenApi.Interfaces.IOpenApiElement { } public static void WriteOptionalObject(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, T? value, System.Action action) { } + public static void WriteOptionalOrEmptyCollection(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.IEnumerable? elements, System.Action action) { } public static void WriteProperty(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, string? value) { } public static void WriteProperty(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, bool value, bool defaultValue = false) { } public static void WriteProperty(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, bool? value, bool defaultValue = false) { } From 1be53699ff241cf9307ea5f0f781f7195e7df645 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Tue, 13 May 2025 07:35:36 +0000 Subject: [PATCH 124/984] chore(main): release 2.0.0-preview.18 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 16 ++++++++++++++++ Directory.Build.props | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index d5ba1e810..47dc98266 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "2.0.0-preview.17" + ".": "2.0.0-preview.18" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 740522c4d..6783dbc30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,21 @@ # Changelog +## [2.0.0-preview.18](https://github.com/microsoft/OpenAPI.NET/compare/v2.0.0-preview.17...v2.0.0-preview.18) (2025-05-13) + + +### Features + +* upgrades openapi.net.odata and apimanifest to the latest version ([80844a6](https://github.com/microsoft/OpenAPI.NET/commit/80844a60ae50ba0a4d54d7dd2e45ce8360206bf5)) +* upgrades openapi.net.odata and apimanifest to the latest version ([938a2e0](https://github.com/microsoft/OpenAPI.NET/commit/938a2e07b40b082e01ed1cdf3244767cbdca4061)) + + +### Bug Fixes + +* avoid calling virtual members in constructor ([5835057](https://github.com/microsoft/OpenAPI.NET/commit/5835057a7e905e371f859e727ddaf65ec08c6db0)) +* Fix typo in error message ([#2345](https://github.com/microsoft/OpenAPI.NET/issues/2345)) ([3f8b2b9](https://github.com/microsoft/OpenAPI.NET/commit/3f8b2b99c07bd3c58825728c2dd2ffed91d88fbe)) +* handle deserializing and writing empty security requirements [#1426](https://github.com/microsoft/OpenAPI.NET/issues/1426) ([#2323](https://github.com/microsoft/OpenAPI.NET/issues/2323)) ([962e0e4](https://github.com/microsoft/OpenAPI.NET/commit/962e0e436f96b1b68613013d75307dc1f92ce15c)) +* normalized override implementation for parameter types serialization in v2 ([5930916](https://github.com/microsoft/OpenAPI.NET/commit/593091621926defcbc2727a922613e34557d882a)) + ## [2.0.0-preview.17](https://github.com/microsoft/OpenAPI.NET/compare/v2.0.0-preview.16...v2.0.0-preview.17) (2025-04-16) diff --git a/Directory.Build.props b/Directory.Build.props index 7e245bef5..751877ce6 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -12,7 +12,7 @@ https://github.com/Microsoft/OpenAPI.NET © Microsoft Corporation. All rights reserved. OpenAPI .NET - 2.0.0-preview.17 + 2.0.0-preview.18 From 09cd4af1e38c913b4cf7fc988fc552e2664ec61c Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Tue, 13 May 2025 11:02:05 +0300 Subject: [PATCH 125/984] chore: update doc to include use of bitwise OR, AND and NOT operators --- docs/upgrade-guide-2.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/docs/upgrade-guide-2.md b/docs/upgrade-guide-2.md index d6121a624..5a9f18f42 100644 --- a/docs/upgrade-guide-2.md +++ b/docs/upgrade-guide-2.md @@ -543,9 +543,22 @@ var schema = new OpenApiSchema } // v2.0 +// bitwise OR(|) - combines flags to allow multiple types var schema = new OpenApiSchema { - Type = JsonSchemaType.String | JsonSchemaType.Null + Type = JsonSchemaType.String | JsonSchemaType.Null +} + +// bitwise NOT(~) - inverts bits; filters out null flag +var schema = new OpenApiSchema +{ + Type = JsonSchemaType.String & ~JsonSchemaType.Null +} + +// bitwise AND(&) - intersects flags to check for a specific type +var schema = new OpenApiSchema +{ + Type = (JsonSchemaType.String & JsonSchemaType.Null) == JsonSchemaType.Null } ``` From 8f15c33ad4e95fc1a90ce91f2b4478cada7db6f2 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Tue, 13 May 2025 16:13:44 +0300 Subject: [PATCH 126/984] chore: remove unnecessary project reference --- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index e95792d72..d6d8a21b5 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -26,7 +26,6 @@ - From fdfe002d551fc3feaaeb5af24042826f13bdf412 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Wed, 14 May 2025 14:30:35 -0400 Subject: [PATCH 127/984] fix: discriminator mapping references don't get a document when created from DOM Signed-off-by: Vincent Biret --- .../Services/OpenApiWalker.cs | 24 +++++++++++++++++++ .../Walkers/WalkerLocationTests.cs | 21 ++++++++++++++-- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi/Services/OpenApiWalker.cs b/src/Microsoft.OpenApi/Services/OpenApiWalker.cs index 56eea541a..ac8027bae 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiWalker.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiWalker.cs @@ -932,6 +932,8 @@ internal void Walk(IOpenApiSchema? schema, bool isComponent = false) Walk("additionalProperties", () => Walk(schema.AdditionalProperties)); } + Walk("discriminator", () => Walk(schema.Discriminator)); + Walk(OpenApiConstants.ExternalDocs, () => Walk(schema.ExternalDocs)); Walk(schema as IOpenApiExtensible); @@ -939,6 +941,27 @@ internal void Walk(IOpenApiSchema? schema, bool isComponent = false) _schemaLoop.Pop(); } + internal void Walk(OpenApiDiscriminator? openApiDiscriminator) + { + if (openApiDiscriminator == null) + { + return; + } + + _visitor.Visit(openApiDiscriminator); + + if (openApiDiscriminator.Mapping != null) + { + Walk("mapping", () => + { + foreach (var item in openApiDiscriminator.Mapping) + { + Walk(item.Key, () => Walk((IOpenApiSchema)item.Value)); + } + }); + } + } + /// /// Visits dictionary of @@ -1215,6 +1238,7 @@ internal void Walk(IOpenApiElement element) case OpenApiRequestBody e: Walk(e); break; case OpenApiResponse e: Walk(e); break; case OpenApiSchema e: Walk(e); break; + case OpenApiDiscriminator e: Walk(e); break; case OpenApiSecurityRequirement e: Walk(e); break; case OpenApiSecurityScheme e: Walk(e); break; case OpenApiServer e: Walk(e); break; diff --git a/test/Microsoft.OpenApi.Tests/Walkers/WalkerLocationTests.cs b/test/Microsoft.OpenApi.Tests/Walkers/WalkerLocationTests.cs index 01f3c223b..862179b6f 100644 --- a/test/Microsoft.OpenApi.Tests/Walkers/WalkerLocationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Walkers/WalkerLocationTests.cs @@ -158,7 +158,23 @@ public void WalkDOMWithCycles() [Fact] public void LocateReferences() { - var baseSchema = new OpenApiSchema(); + var baseSchema = new OpenApiSchema + { + Type = JsonSchemaType.Object, + Properties = new() + { + ["type"] = new OpenApiSchema() { Type = JsonSchemaType.String } + }, + Required = new HashSet { "type" }, + Discriminator = new OpenApiDiscriminator + { + PropertyName = "type", + Mapping = new Dictionary + { + ["derived"] = new OpenApiSchemaReference("derived") + } + } + }; var derivedSchema = new OpenApiSchema { @@ -229,7 +245,8 @@ public void LocateReferences() "referenceAt: #/paths/~1/get/responses/200/headers/test-header", "referenceAt: #/components/schemas/derived/anyOf/0", "referenceAt: #/components/securitySchemes/test-secScheme", - "referenceAt: #/components/headers/test-header/schema" + "referenceAt: #/components/headers/test-header/schema", + "referenceAt: #/components/schemas/base/discriminator/mapping/derived", }, locator.Locations.Where(l => l.StartsWith("referenceAt:", StringComparison.OrdinalIgnoreCase))); } } From cb6835983d06b72e67266e1c31fbfcc50faf2c61 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Wed, 14 May 2025 15:48:44 -0400 Subject: [PATCH 128/984] chore: updates benchmark results --- .../performance.Descriptions-report-github.md | 16 ++--- .../performance.Descriptions-report.csv | 8 +-- .../performance.Descriptions-report.html | 18 ++--- .../performance.Descriptions-report.json | 2 +- .../performance.EmptyModels-report-github.md | 68 +++++++++---------- .../performance.EmptyModels-report.csv | 58 ++++++++-------- .../performance.EmptyModels-report.html | 68 +++++++++---------- .../performance.EmptyModels-report.json | 2 +- 8 files changed, 120 insertions(+), 120 deletions(-) diff --git a/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.Descriptions-report-github.md b/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.Descriptions-report-github.md index e1ca8eed6..a507dd8e9 100644 --- a/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.Descriptions-report-github.md +++ b/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.Descriptions-report-github.md @@ -1,10 +1,10 @@ ``` -BenchmarkDotNet v0.14.0, Windows 11 (10.0.26100.3476) +BenchmarkDotNet v0.14.0, Windows 11 (10.0.26100.3981) 11th Gen Intel Core i7-1185G7 3.00GHz, 1 CPU, 8 logical and 4 physical cores -.NET SDK 8.0.408 - [Host] : .NET 8.0.15 (8.0.1525.16413), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI - ShortRun : .NET 8.0.15 (8.0.1525.16413), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI +.NET SDK 8.0.409 + [Host] : .NET 8.0.16 (8.0.1625.21506), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI + ShortRun : .NET 8.0.16 (8.0.1625.21506), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI Job=ShortRun IterationCount=3 LaunchCount=1 WarmupCount=3 @@ -12,7 +12,7 @@ WarmupCount=3 ``` | Method | Mean | Error | StdDev | Gen0 | Gen1 | Gen2 | Allocated | |------------- |-------------:|--------------:|-------------:|-----------:|-----------:|----------:|-------------:| -| PetStoreYaml | 450.5 μs | 59.26 μs | 3.25 μs | 58.5938 | 11.7188 | - | 377.15 KB | -| PetStoreJson | 172.8 μs | 123.46 μs | 6.77 μs | 39.0625 | 7.8125 | - | 239.29 KB | -| GHESYaml | 943,452.7 μs | 137,685.49 μs | 7,547.01 μs | 66000.0000 | 21000.0000 | 3000.0000 | 389463.91 KB | -| GHESJson | 468,401.8 μs | 300,711.80 μs | 16,483.03 μs | 41000.0000 | 15000.0000 | 3000.0000 | 250934.62 KB | +| PetStoreYaml | 470.3 μs | 138.05 μs | 7.57 μs | 58.5938 | 11.7188 | - | 380.53 KB | +| PetStoreJson | 166.0 μs | 43.84 μs | 2.40 μs | 39.0625 | 8.7891 | - | 242.67 KB | +| GHESYaml | 915,406.4 μs | 714,492.62 μs | 39,163.75 μs | 68000.0000 | 22000.0000 | 4000.0000 | 395800.98 KB | +| GHESJson | 470,609.4 μs | 264,698.88 μs | 14,509.04 μs | 42000.0000 | 15000.0000 | 3000.0000 | 257270.45 KB | diff --git a/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.Descriptions-report.csv b/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.Descriptions-report.csv index ff86e86e7..e6299ad40 100644 --- a/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.Descriptions-report.csv +++ b/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.Descriptions-report.csv @@ -1,5 +1,5 @@ Method,Job,AnalyzeLaunchVariance,EvaluateOverhead,MaxAbsoluteError,MaxRelativeError,MinInvokeCount,MinIterationTime,OutlierMode,Affinity,EnvironmentVariables,Jit,LargeAddressAware,Platform,PowerPlanMode,Runtime,AllowVeryLargeObjects,Concurrent,CpuGroups,Force,HeapAffinitizeMask,HeapCount,NoAffinitize,RetainVm,Server,Arguments,BuildConfiguration,Clock,EngineFactory,NuGetReferences,Toolchain,IsMutator,InvocationCount,IterationCount,IterationTime,LaunchCount,MaxIterationCount,MaxWarmupIterationCount,MemoryRandomization,MinIterationCount,MinWarmupIterationCount,RunStrategy,UnrollFactor,WarmupCount,Mean,Error,StdDev,Gen0,Gen1,Gen2,Allocated -PetStoreYaml,ShortRun,False,Default,Default,Default,Default,Default,Default,11111111,Empty,RyuJit,Default,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,450.5 μs,59.26 μs,3.25 μs,58.5938,11.7188,0.0000,377.15 KB -PetStoreJson,ShortRun,False,Default,Default,Default,Default,Default,Default,11111111,Empty,RyuJit,Default,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,172.8 μs,123.46 μs,6.77 μs,39.0625,7.8125,0.0000,239.29 KB -GHESYaml,ShortRun,False,Default,Default,Default,Default,Default,Default,11111111,Empty,RyuJit,Default,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,"943,452.7 μs","137,685.49 μs","7,547.01 μs",66000.0000,21000.0000,3000.0000,389463.91 KB -GHESJson,ShortRun,False,Default,Default,Default,Default,Default,Default,11111111,Empty,RyuJit,Default,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,"468,401.8 μs","300,711.80 μs","16,483.03 μs",41000.0000,15000.0000,3000.0000,250934.62 KB +PetStoreYaml,ShortRun,False,Default,Default,Default,Default,Default,Default,11111111,Empty,RyuJit,Default,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,470.3 μs,138.05 μs,7.57 μs,58.5938,11.7188,0.0000,380.53 KB +PetStoreJson,ShortRun,False,Default,Default,Default,Default,Default,Default,11111111,Empty,RyuJit,Default,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,166.0 μs,43.84 μs,2.40 μs,39.0625,8.7891,0.0000,242.67 KB +GHESYaml,ShortRun,False,Default,Default,Default,Default,Default,Default,11111111,Empty,RyuJit,Default,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,"915,406.4 μs","714,492.62 μs","39,163.75 μs",68000.0000,22000.0000,4000.0000,395800.98 KB +GHESJson,ShortRun,False,Default,Default,Default,Default,Default,Default,11111111,Empty,RyuJit,Default,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,"470,609.4 μs","264,698.88 μs","14,509.04 μs",42000.0000,15000.0000,3000.0000,257270.45 KB diff --git a/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.Descriptions-report.html b/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.Descriptions-report.html index 497e2dda7..4f578eca3 100644 --- a/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.Descriptions-report.html +++ b/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.Descriptions-report.html @@ -2,7 +2,7 @@ -performance.Descriptions-20250409-150544 +performance.Descriptions-20250514-154213 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/Microsoft.OpenApi.Workbench/Themes/Metro/Styles.WPF.xaml b/src/Microsoft.OpenApi.Workbench/Themes/Metro/Styles.WPF.xaml deleted file mode 100644 index 988e787b8..000000000 --- a/src/Microsoft.OpenApi.Workbench/Themes/Metro/Styles.WPF.xaml +++ /dev/null @@ -1,830 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Visible - - - - - - - - - - - Visible - - - - - - - - - - - - - - Visible - - - - - - - - - - - Visible - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/Microsoft.OpenApi.Workbench/Themes/Metro/Theme.Colors.xaml b/src/Microsoft.OpenApi.Workbench/Themes/Metro/Theme.Colors.xaml deleted file mode 100644 index 02babe07a..000000000 --- a/src/Microsoft.OpenApi.Workbench/Themes/Metro/Theme.Colors.xaml +++ /dev/null @@ -1,89 +0,0 @@ - - - - - - - - - - - - #FF282828 - #FF3F3F3F - #FF565656 - #FF858585 - #FFB9B9B9 - #FFD7D7D7 - #FFE7E7E7 - #FFF4F4F4 - #FFF9F9F9 - #FFFFFFFF - - - #E5FFFFFF - #BFFFFFFF - #99FFFFFF - #72FFFFFF - #4CFFFFFF - #00FFFFFF - - - #72000000 - #4C000000 - #26000000 - #00000000 - #66E2E2E2 - - - #FF0086AF - #FF00AADE - #FF80D5EF - #FFB2E1EF - #2600AADE - - - #FFD0284C - #FFF55E7F - #FFFFCAD5 - - - #FF006481 - #FF8A9B0F - #FF3E4700 - #FFF14D0F - #FF8D2E00 - #FF81106B - #FF410135 - #FFFCA910 - #FF8D4902 - #FF037A54 - #FF003F2A - #FF154D85 - #FF02284D - #FF543511 - #FF211303 - #FF89806D - #FF393225 - #FF58458B - #FF211347 - #7FB9B9B9 - #33565656 - #7F3F3F3F - #FF686868 - #8000AADE - #CC3F3F3F - - - - #FF0092BE - #FF00AADE - #FF2BB9E5 - #FF55C8EB - #FF80D7F2 - - \ No newline at end of file From afd4967a9e6db390175e2df9e6f34ff77168d19d Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Fri, 11 Sep 2026 12:04:07 -0700 Subject: [PATCH 921/984] Omit null OpenAPI response descriptions (#3077) * Initial plan fix(openapi): omit null response descriptions Co-authored-by: baywet <7905502+baywet@users.noreply.github.com> * test(models): update response serialization expectation Co-authored-by: baywet <7905502+baywet@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: baywet <7905502+baywet@users.noreply.github.com> --- .../Models/OpenApiResponse.cs | 8 +++---- .../OpenApiResponseSerializationTests.cs | 22 +++++++++++++++++++ .../Models/OpenApiOperationTests.cs | 4 ---- .../Models/OpenApiResponseTests.cs | 4 +--- 4 files changed, 27 insertions(+), 11 deletions(-) diff --git a/src/Microsoft.OpenApi/Models/OpenApiResponse.cs b/src/Microsoft.OpenApi/Models/OpenApiResponse.cs index 4ee39336e..6bd02af25 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiResponse.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiResponse.cs @@ -73,7 +73,7 @@ public virtual void SerializeAsV3(IOpenApiWriter writer) SerializeInternal(writer, OpenApiSpecVersion.OpenApi3_0, (writer, element) => element.SerializeAsV3(writer)); } - private void SerializeInternal(IOpenApiWriter writer, OpenApiSpecVersion version, + private void SerializeInternal(IOpenApiWriter writer, OpenApiSpecVersion version, Action callback) { Utils.CheckArgumentNull(writer); @@ -87,7 +87,7 @@ private void SerializeInternal(IOpenApiWriter writer, OpenApiSpecVersion version } // description - writer.WriteRequiredProperty(OpenApiConstants.Description, Description); + writer.WriteProperty(OpenApiConstants.Description, Description); // headers writer.WriteOptionalMap(OpenApiConstants.Headers, Headers, callback); @@ -120,7 +120,7 @@ public virtual void SerializeAsV2(IOpenApiWriter writer) writer.WriteStartObject(); // description - writer.WriteRequiredProperty(OpenApiConstants.Description, Description); + writer.WriteProperty(OpenApiConstants.Description, Description); var extensionsClone = Extensions is not null ? new Dictionary(Extensions) : null; @@ -177,7 +177,7 @@ public virtual void SerializeAsV2(IOpenApiWriter writer) // so remove it from the cloned collection so we don't write it again. extensionsClone?.Remove(key); } - } + } } } diff --git a/test/Microsoft.OpenApi.Tests/Mocks/OpenApiResponseSerializationTests.cs b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiResponseSerializationTests.cs index 27246fa7e..95a5a6980 100644 --- a/test/Microsoft.OpenApi.Tests/Mocks/OpenApiResponseSerializationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Mocks/OpenApiResponseSerializationTests.cs @@ -1,5 +1,7 @@ using System.IO; using System.Net.Http; +using System.Text.Json.Nodes; +using System.Threading.Tasks; using Moq; using Xunit; @@ -61,5 +63,25 @@ public void SerializeAsV3_DoesNotCallV31OrV2Serialization() _linkMock.Verify(l => l.SerializeAsV31(It.IsAny()), Times.Never); _linkMock.Verify(l => l.SerializeAsV2(It.IsAny()), Times.Never); } + + [Theory] + [InlineData(OpenApiSpecVersion.OpenApi2_0)] + [InlineData(OpenApiSpecVersion.OpenApi3_0)] + [InlineData(OpenApiSpecVersion.OpenApi3_1)] + [InlineData(OpenApiSpecVersion.OpenApi3_2)] + public async Task SerializeResponseWithoutDescriptionAsJsonDoesNotWriteNullDescription(OpenApiSpecVersion specVersion) + { + // Arrange + var response = new OpenApiResponse(); + + // Act + var actual = await response.SerializeAsJsonAsync(specVersion, TestContext.Current.CancellationToken); + + // Assert + var node = JsonNode.Parse(actual); + Assert.NotNull(node); + var responseObject = Assert.IsType(node); + Assert.False(responseObject.ContainsKey(OpenApiConstants.Description)); + } } } diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs index 4dab19e76..d281f4437 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs @@ -343,7 +343,6 @@ public async Task SerializeOperationWithBodyAsV3JsonWorks() "$ref": "#/components/responses/response1" }, "400": { - "description": null, "content": { "application/json": { "schema": { @@ -416,7 +415,6 @@ public async Task SerializeAdvancedOperationWithTagAndSecurityAsV3JsonWorks() "$ref": "#/components/responses/response1" }, "400": { - "description": null, "content": { "application/json": { "schema": { @@ -648,7 +646,6 @@ public async Task SerializeOperationWithBodyAsV2JsonWorks() "$ref": "#/responses/response1" }, "400": { - "description": null, "schema": { "type": "number", "maximum": 10, @@ -718,7 +715,6 @@ public async Task SerializeAdvancedOperationWithTagAndSecurityAsV2JsonWorks() "$ref": "#/responses/response1" }, "400": { - "description": null, "schema": { "type": "number", "maximum": 10, diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.cs index 450058fe1..fdd291162 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.cs @@ -193,9 +193,7 @@ public async Task SerializeBasicResponseWorks( string format) { // Arrange - var expected = format == OpenApiConstants.Json ? @"{ - ""description"": null -}" : @"description: null"; + var expected = @"{ }"; // Act var actual = await BasicResponse.SerializeAsync(version, format, TestContext.Current.CancellationToken); From c35be9bbe33dbb038f5b3d45f12f49dba8859e66 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 16 Sep 2026 05:36:05 -0400 Subject: [PATCH 922/984] Bump Microsoft.SourceLink.GitHub from 10.0.400 to 10.0.401 (#3085) --- updated-dependencies: - dependency-name: Microsoft.SourceLink.GitHub dependency-version: 10.0.401 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index da0a45c5d..5c2dfa48a 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -19,6 +19,6 @@ true - + \ No newline at end of file From 413f0aa52e1cede721b70a99cc8b92ec5d4984a1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 16 Sep 2026 05:36:47 -0400 Subject: [PATCH 923/984] Bump the microsoftextensions group with 6 updates (#3084) Bumps Microsoft.Extensions.DependencyInjection from 10.0.11 to 10.0.12 Bumps Microsoft.Extensions.Logging from 10.0.11 to 10.0.12 Bumps Microsoft.Extensions.Logging.Abstractions from 10.0.11 to 10.0.12 Bumps Microsoft.Extensions.Logging.Console from 10.0.11 to 10.0.12 Bumps Microsoft.Extensions.Logging.Debug from 10.0.11 to 10.0.12 Bumps System.Text.Json from 10.0.11 to 10.0.12 --- updated-dependencies: - dependency-name: Microsoft.Extensions.DependencyInjection dependency-version: 10.0.12 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: microsoftextensions - dependency-name: Microsoft.Extensions.Logging dependency-version: 10.0.12 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: microsoftextensions - dependency-name: Microsoft.Extensions.Logging dependency-version: 10.0.12 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: microsoftextensions - dependency-name: Microsoft.Extensions.Logging.Abstractions dependency-version: 10.0.12 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: microsoftextensions - dependency-name: Microsoft.Extensions.Logging.Console dependency-version: 10.0.12 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: microsoftextensions - dependency-name: System.Text.Json dependency-version: 10.0.12 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: microsoftextensions - dependency-name: Microsoft.Extensions.Logging.Console dependency-version: 10.0.12 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: microsoftextensions - dependency-name: Microsoft.Extensions.Logging.Debug dependency-version: 10.0.12 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: microsoftextensions - dependency-name: Microsoft.Extensions.Logging.Debug dependency-version: 10.0.12 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: microsoftextensions ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- performance/resultsComparer/resultsComparer.csproj | 10 +++++----- .../Microsoft.OpenApi.Hidi.csproj | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/performance/resultsComparer/resultsComparer.csproj b/performance/resultsComparer/resultsComparer.csproj index c6a0f2d33..9767a28ba 100644 --- a/performance/resultsComparer/resultsComparer.csproj +++ b/performance/resultsComparer/resultsComparer.csproj @@ -8,12 +8,12 @@ - - - - + + + + - + diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index 5e2fd04ed..fab3173fd 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -29,10 +29,10 @@ - - - - + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all From fb595ec43c7ef66d2adbf47d60cfa70a573b1394 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 16 Sep 2026 05:37:11 -0400 Subject: [PATCH 924/984] chore(deps): bump dotnet-sdk from 10.0.400 to 10.0.401 (#3083) Bumps [dotnet-sdk](https://github.com/dotnet/sdk) from 10.0.400 to 10.0.401. - [Release notes](https://github.com/dotnet/sdk/releases) - [Commits](https://github.com/dotnet/sdk/compare/v10.0.400...v10.0.401) --- updated-dependencies: - dependency-name: dotnet-sdk dependency-version: 10.0.401 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index 2f38dd557..7494875e1 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "10.0.400" + "version": "10.0.401" }, "test": { "runner": "Microsoft.Testing.Platform" From 0afae131bf68a03b7133818b24584ac6d956fc73 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 17 Sep 2026 05:47:47 -0400 Subject: [PATCH 925/984] chore(deps): bump actions/setup-java from 6.0.0 to 6.0.1 (#3087) Bumps [actions/setup-java](https://github.com/actions/setup-java) from 6.0.0 to 6.0.1. - [Release notes](https://github.com/actions/setup-java/releases) - [Commits](https://github.com/actions/setup-java/compare/dd06d9cba3e5552c54d9f8ea23572deb30010f7c...de7274f081f381c8f8158605e0321c36c376e2e6) --- updated-dependencies: - dependency-name: actions/setup-java dependency-version: 6.0.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/sonarcloud.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index a75019cfd..a6954d70d 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -35,7 +35,7 @@ jobs: runs-on: windows-latest steps: - name: Set up JDK 17 - uses: actions/setup-java@dd06d9cba3e5552c54d9f8ea23572deb30010f7c # v6.0.0 + uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # v6.0.1 with: distribution: 'temurin' java-version: 17 From 3ced884842911823d597072d4e786872d2cc44ce Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 17 Sep 2026 05:58:28 -0400 Subject: [PATCH 926/984] Bump the testing group with 1 update (#3088) Bumps Microsoft.NET.Test.Sdk from 18.9.0 to 18.10.0 --- updated-dependencies: - dependency-name: Microsoft.NET.Test.Sdk dependency-version: 18.10.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: testing - dependency-name: Microsoft.NET.Test.Sdk dependency-version: 18.10.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: testing ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .../Microsoft.OpenApi.Hidi.Tests.csproj | 2 +- .../Microsoft.OpenApi.Readers.Tests.csproj | 2 +- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj index 2271cbb81..3e5f82aa4 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj +++ b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj @@ -15,7 +15,7 @@ - + diff --git a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj index e3601ba20..9598b058d 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj +++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj @@ -17,7 +17,7 @@ - + diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 0a681a46c..1185dd65c 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -10,7 +10,7 @@ - + From 7adeb08e04bb1c4338399eb24742b728fd47dd5c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 17 Sep 2026 05:59:03 -0400 Subject: [PATCH 927/984] chore(deps): bump the codeql group with 2 updates (#3086) Bumps the codeql group with 2 updates: [github/codeql-action/init](https://github.com/github/codeql-action) and [github/codeql-action/analyze](https://github.com/github/codeql-action). Updates `github/codeql-action/init` from 4.37.9 to 4.38.0 - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/codeql-action/compare/cdf488f595d80d6e07e03d4674febd5ab45fa938...b96794f015dfd88f77b49b1c93e0fa7110f94c63) Updates `github/codeql-action/analyze` from 4.37.9 to 4.38.0 - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/codeql-action/compare/cdf488f595d80d6e07e03d4674febd5ab45fa938...b96794f015dfd88f77b49b1c93e0fa7110f94c63) --- updated-dependencies: - dependency-name: github/codeql-action/init dependency-version: 4.38.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: codeql - dependency-name: github/codeql-action/analyze dependency-version: 4.38.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: codeql ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/codeql-analysis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index cb35bda68..e3cb62f4a 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -34,7 +34,7 @@ jobs: - name: Initialize CodeQL id: init_codeql - uses: github/codeql-action/init@cdf488f595d80d6e07e03d4674febd5ab45fa938 # v4.37.9 + uses: github/codeql-action/init@b96794f015dfd88f77b49b1c93e0fa7110f94c63 # v4.38.0 with: queries: security-and-quality @@ -54,6 +54,6 @@ jobs: - name: Perform CodeQL Analysis id: analyze_codeql - uses: github/codeql-action/analyze@cdf488f595d80d6e07e03d4674febd5ab45fa938 # v4.37.9 + uses: github/codeql-action/analyze@b96794f015dfd88f77b49b1c93e0fa7110f94c63 # v4.38.0 # Built with ❤ by [Pipeline Foundation](https://pipeline.foundation) \ No newline at end of file From fde81d9200c89a501094d47a75904f9896fb27f5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 22 Sep 2026 07:03:28 -0400 Subject: [PATCH 928/984] Bump the testing group with 1 update (#3090) Bumps xunit.v3 from 4.0.0 to 4.0.1 --- updated-dependencies: - dependency-name: xunit.v3 dependency-version: 4.0.1 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: testing - dependency-name: xunit.v3 dependency-version: 4.0.1 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: testing ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .../Microsoft.OpenApi.Hidi.Tests.csproj | 2 +- .../Microsoft.OpenApi.Readers.Tests.csproj | 2 +- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj index 3e5f82aa4..64690e433 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj +++ b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj @@ -19,7 +19,7 @@ - + diff --git a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj index 9598b058d..eea3476a0 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj +++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj @@ -20,7 +20,7 @@ - + diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 1185dd65c..5275f1ba8 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -15,7 +15,7 @@ - + From 4450d5fff83c29e4717214c4777d77e987585a3e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 22 Sep 2026 10:20:15 -0700 Subject: [PATCH 929/984] Bump Verify.XunitV3 from 32.0.0 to 33.0.2 (#3091) * Bump Verify.XunitV3 from 32.0.0 to 33.0.2 --- updated-dependencies: - dependency-name: Verify.XunitV3 dependency-version: 33.0.2 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] * chore(dependencies): declare Verify open source exemption Co-authored-by: baywet <7905502+baywet@users.noreply.github.com> --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: baywet <7905502+baywet@users.noreply.github.com> --- Directory.Build.props | 2 ++ test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 5c2dfa48a..1971fa2c6 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 + OpenSource + 2027-09 http://go.microsoft.com/fwlink/?LinkID=288890 https://github.com/Microsoft/OpenAPI.NET © Microsoft Corporation. All rights reserved. diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 5275f1ba8..07876a331 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -14,7 +14,7 @@ - + From f262b83ddbab37f3b04475876e058dae869dfc17 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 22 Sep 2026 17:35:33 -0400 Subject: [PATCH 930/984] Bump the testing group with 1 update (#3092) Bumps Microsoft.NET.Test.Sdk from 18.10.0 to 18.10.1 --- updated-dependencies: - dependency-name: Microsoft.NET.Test.Sdk dependency-version: 18.10.1 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: testing - dependency-name: Microsoft.NET.Test.Sdk dependency-version: 18.10.1 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: testing ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .../Microsoft.OpenApi.Hidi.Tests.csproj | 2 +- .../Microsoft.OpenApi.Readers.Tests.csproj | 2 +- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj index 64690e433..5e9e7ede9 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj +++ b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj @@ -15,7 +15,7 @@ - + diff --git a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj index eea3476a0..4ec972381 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj +++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj @@ -17,7 +17,7 @@ - + diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 07876a331..4c7ecf73b 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -10,7 +10,7 @@ - + From 5c2db299ccb729226a243cd577361c4a32e4e069 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 23 Sep 2026 17:46:12 -0400 Subject: [PATCH 931/984] Bump the testing group with 2 updates (#3093) Bumps Microsoft.Testing.Extensions.AzureDevOpsReport from 2.4.0 to 2.4.1 Bumps Microsoft.Testing.Extensions.GitHubActionsReport from 2.4.0 to 2.4.1 --- updated-dependencies: - dependency-name: Microsoft.Testing.Extensions.AzureDevOpsReport dependency-version: 2.4.1 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: testing - dependency-name: Microsoft.Testing.Extensions.AzureDevOpsReport dependency-version: 2.4.1 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: testing - dependency-name: Microsoft.Testing.Extensions.GitHubActionsReport dependency-version: 2.4.1 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: testing - dependency-name: Microsoft.Testing.Extensions.GitHubActionsReport dependency-version: 2.4.1 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: testing ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .../Microsoft.OpenApi.Hidi.Tests.csproj | 4 ++-- .../Microsoft.OpenApi.Readers.Tests.csproj | 4 ++-- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj index 5e9e7ede9..a32deb9b6 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj +++ b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj @@ -16,8 +16,8 @@ - - + + 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 4ec972381..e75ef4bcb 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj +++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj @@ -18,8 +18,8 @@ - - + + diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 4c7ecf73b..32e6a5056 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -11,8 +11,8 @@ - - + + From efede53130f56ccf7737204fa3d8630507cddd0d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 28 Sep 2026 06:59:35 -0400 Subject: [PATCH 932/984] chore(deps): bump the codeql group with 2 updates (#3094) Bumps the codeql group with 2 updates: [github/codeql-action/init](https://github.com/github/codeql-action) and [github/codeql-action/analyze](https://github.com/github/codeql-action). Updates `github/codeql-action/init` from 4.38.0 to 4.38.1 - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/codeql-action/compare/b96794f015dfd88f77b49b1c93e0fa7110f94c63...1c5b675653bb5c22dbe9b12b556ec555138e09fd) Updates `github/codeql-action/analyze` from 4.38.0 to 4.38.1 - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/codeql-action/compare/b96794f015dfd88f77b49b1c93e0fa7110f94c63...1c5b675653bb5c22dbe9b12b556ec555138e09fd) --- updated-dependencies: - dependency-name: github/codeql-action/init dependency-version: 4.38.1 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: codeql - dependency-name: github/codeql-action/analyze dependency-version: 4.38.1 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: codeql ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/codeql-analysis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index e3cb62f4a..e3ac2cc16 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -34,7 +34,7 @@ jobs: - name: Initialize CodeQL id: init_codeql - uses: github/codeql-action/init@b96794f015dfd88f77b49b1c93e0fa7110f94c63 # v4.38.0 + uses: github/codeql-action/init@1c5b675653bb5c22dbe9b12b556ec555138e09fd # v4.38.1 with: queries: security-and-quality @@ -54,6 +54,6 @@ jobs: - name: Perform CodeQL Analysis id: analyze_codeql - uses: github/codeql-action/analyze@b96794f015dfd88f77b49b1c93e0fa7110f94c63 # v4.38.0 + uses: github/codeql-action/analyze@1c5b675653bb5c22dbe9b12b556ec555138e09fd # v4.38.1 # Built with ❤ by [Pipeline Foundation](https://pipeline.foundation) \ No newline at end of file From c719c42443db950eef44f8f6ce0c317f2ee98117 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Mon, 28 Sep 2026 14:36:28 -0400 Subject: [PATCH 933/984] ci: Change auto-merge strategy for Dependabot PRs (#3095) --- .github/workflows/auto-merge-dependabot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/auto-merge-dependabot.yml b/.github/workflows/auto-merge-dependabot.yml index a3343774e..f6dafa170 100644 --- a/.github/workflows/auto-merge-dependabot.yml +++ b/.github/workflows/auto-merge-dependabot.yml @@ -26,7 +26,7 @@ jobs: - name: Enable auto-merge for Dependabot PRs # Only if version bump is not a major version change if: ${{steps.metadata.outputs.update-type != 'version-update:semver-major'}} - run: gh pr merge --auto --merge "$PR_URL" + run: gh pr merge --auto --squash "$PR_URL" env: PR_URL: ${{github.event.pull_request.html_url}} GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} From 2fc1ed9aa9074fee02f2de1e7a49f56398f39d1c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 28 Sep 2026 19:33:28 -0400 Subject: [PATCH 934/984] Bump Verify.XunitV3 from 33.0.2 to 33.1.1 (#3096) --- updated-dependencies: - dependency-name: Verify.XunitV3 dependency-version: 33.1.1 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- 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 32e6a5056..92745edea 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -14,7 +14,7 @@ - + From eebc63ccd29f89b850f5fd43f56f733b77aed985 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 2 Oct 2026 06:55:36 -0400 Subject: [PATCH 935/984] chore(deps): bump the codeql group with 2 updates (#3097) Bumps the codeql group with 2 updates: [github/codeql-action/init](https://github.com/github/codeql-action) and [github/codeql-action/analyze](https://github.com/github/codeql-action). Updates `github/codeql-action/init` from 4.38.1 to 4.38.2 - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/codeql-action/compare/1c5b675653bb5c22dbe9b12b556ec555138e09fd...2892aa5e19bbd11bc0cff5427e3b750a04d9e3c2) Updates `github/codeql-action/analyze` from 4.38.1 to 4.38.2 - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/codeql-action/compare/1c5b675653bb5c22dbe9b12b556ec555138e09fd...2892aa5e19bbd11bc0cff5427e3b750a04d9e3c2) --- updated-dependencies: - dependency-name: github/codeql-action/init dependency-version: 4.38.2 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: codeql - dependency-name: github/codeql-action/analyze dependency-version: 4.38.2 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: codeql ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/codeql-analysis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index e3ac2cc16..b2311adf8 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -34,7 +34,7 @@ jobs: - name: Initialize CodeQL id: init_codeql - uses: github/codeql-action/init@1c5b675653bb5c22dbe9b12b556ec555138e09fd # v4.38.1 + uses: github/codeql-action/init@2892aa5e19bbd11bc0cff5427e3b750a04d9e3c2 # v4.38.2 with: queries: security-and-quality @@ -54,6 +54,6 @@ jobs: - name: Perform CodeQL Analysis id: analyze_codeql - uses: github/codeql-action/analyze@1c5b675653bb5c22dbe9b12b556ec555138e09fd # v4.38.1 + uses: github/codeql-action/analyze@2892aa5e19bbd11bc0cff5427e3b750a04d9e3c2 # v4.38.2 # Built with ❤ by [Pipeline Foundation](https://pipeline.foundation) \ No newline at end of file From 887bad8eb68c147a432eaabe1223d9293769474b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 2 Oct 2026 06:57:05 -0400 Subject: [PATCH 936/984] Bump Moq from 4.20.72 to 4.21.0 (#3098) --- updated-dependencies: - dependency-name: Moq dependency-version: 4.21.0 dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: Moq dependency-version: 4.21.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .../Microsoft.OpenApi.Hidi.Tests.csproj | 2 +- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj index a32deb9b6..6daa7906a 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj +++ b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj @@ -18,7 +18,7 @@ - + diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 92745edea..469d2cd08 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -13,7 +13,7 @@ - + From 1a7054e6e12edf45e5780cec9a15d2508cb9d9d9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 2 Oct 2026 07:04:10 -0400 Subject: [PATCH 937/984] Bump Verify.XunitV3 from 33.1.1 to 33.1.4 (#3099) --- updated-dependencies: - dependency-name: Verify.XunitV3 dependency-version: 33.1.4 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- 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 469d2cd08..56730da5b 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -14,7 +14,7 @@ - + From 61203495a9721929d39d93ce7928d98067ce051b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 6 Oct 2026 06:49:29 -0400 Subject: [PATCH 938/984] Bump the testing group with 1 update (#3103) Bumps coverlet.MTP from 10.0.1 to 10.1.0 --- updated-dependencies: - dependency-name: coverlet.MTP dependency-version: 10.1.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: testing - dependency-name: coverlet.MTP dependency-version: 10.1.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: testing ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .../Microsoft.OpenApi.Hidi.Tests.csproj | 2 +- .../Microsoft.OpenApi.Readers.Tests.csproj | 2 +- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj index 6daa7906a..c5adf7adc 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj +++ b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj @@ -14,7 +14,7 @@ - + diff --git a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj index e75ef4bcb..ccddceff0 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj +++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj @@ -16,7 +16,7 @@ - + diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 56730da5b..35744dc95 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -9,7 +9,7 @@ - + From 3d0cd0b416f592c12f1dcfd89b38c9ca37714970 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 6 Oct 2026 06:51:08 -0400 Subject: [PATCH 939/984] chore(deps): bump actions/upload-code-coverage from 1.4.2 to 1.4.3 (#3102) Bumps [actions/upload-code-coverage](https://github.com/actions/upload-code-coverage) from 1.4.2 to 1.4.3. - [Release notes](https://github.com/actions/upload-code-coverage/releases) - [Changelog](https://github.com/actions/upload-code-coverage/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/upload-code-coverage/compare/d8e329117199404bba6fc81efe8093dc7c015e34...bfa741d815a28cb064a8e3a0837e577457a017d5) --- updated-dependencies: - dependency-name: actions/upload-code-coverage dependency-version: 1.4.3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci-cd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 60207f6cc..f62a71594 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -64,7 +64,7 @@ jobs: - name: Upload coverage report if: (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]') || (github.event_name != 'pull_request' && github.ref_name == github.event.repository.default_branch) - uses: actions/upload-code-coverage@d8e329117199404bba6fc81efe8093dc7c015e34 # v1.4.2 + uses: actions/upload-code-coverage@bfa741d815a28cb064a8e3a0837e577457a017d5 # v1.4.3 with: file: ./reports/coverage/Cobertura.xml language: CSharp From cdc3c07ad55fd3b2f44d3a7aee2c518d76112f3f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 6 Oct 2026 06:51:36 -0400 Subject: [PATCH 940/984] Bump Verify.XunitV3 from 33.1.4 to 33.1.5 (#3104) --- updated-dependencies: - dependency-name: Verify.XunitV3 dependency-version: 33.1.5 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- 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 35744dc95..299a888f5 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -14,7 +14,7 @@ - + From 8460814f250ce38282e02497f0bbc5e59ec04c31 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 8 Oct 2026 05:54:20 -0400 Subject: [PATCH 941/984] Bump Verify.XunitV3 from 33.1.5 to 33.2.0 (#3105) --- updated-dependencies: - dependency-name: Verify.XunitV3 dependency-version: 33.2.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- 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 299a888f5..e79f44dba 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -14,7 +14,7 @@ - + From 15dca965af7d53ed2de8afc855de45b3455a0238 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 8 Oct 2026 18:23:15 -0400 Subject: [PATCH 942/984] chore(deps): bump actions/upload-code-coverage from 1.4.3 to 1.4.4 (#3106) Bumps [actions/upload-code-coverage](https://github.com/actions/upload-code-coverage) from 1.4.3 to 1.4.4. - [Release notes](https://github.com/actions/upload-code-coverage/releases) - [Changelog](https://github.com/actions/upload-code-coverage/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/upload-code-coverage/compare/bfa741d815a28cb064a8e3a0837e577457a017d5...2b21a77928be8d5168c2b9581a67f2adbebacc52) --- updated-dependencies: - dependency-name: actions/upload-code-coverage dependency-version: 1.4.4 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci-cd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index f62a71594..4ae9e6ae0 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -64,7 +64,7 @@ jobs: - name: Upload coverage report if: (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]') || (github.event_name != 'pull_request' && github.ref_name == github.event.repository.default_branch) - uses: actions/upload-code-coverage@bfa741d815a28cb064a8e3a0837e577457a017d5 # v1.4.3 + uses: actions/upload-code-coverage@2b21a77928be8d5168c2b9581a67f2adbebacc52 # v1.4.4 with: file: ./reports/coverage/Cobertura.xml language: CSharp From e1a75437b76ebfc7c9eb446e9fd0b59a21afb14b Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Fri, 9 Oct 2026 09:18:48 -0600 Subject: [PATCH 943/984] ci(release): publish NuGet via ESRP and authenticate Hidi Docker restores (#3107) * ci(release): publish OpenAPI packages and symbols through ESRP Co-authored-by: baywet <7905502+baywet@users.noreply.github.com> * ci(hidi): authenticate Docker restores using a BuildKit secret Co-authored-by: baywet <7905502+baywet@users.noreply.github.com> * ci(release): share authenticated private-feed version checks Co-authored-by: baywet <7905502+baywet@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: baywet <7905502+baywet@users.noreply.github.com> --- .azure-pipelines/ci-build.yml | 198 ++++++++++++++++++---- Dockerfile | 4 +- scripts/check-nuget-package-published.ps1 | 84 +++++++++ 3 files changed, 256 insertions(+), 30 deletions(-) create mode 100644 scripts/check-nuget-package-published.ps1 diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index 2c8cb8735..5e8a40e98 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -21,6 +21,8 @@ pr: variables: buildPlatform: 'Any CPU' buildConfiguration: 'Release' + NuGetOrganizationName: 'openapinet' + privateFeedBaseUrl: 'https://microsoftgraph.pkgs.visualstudio.com/0985d294-5762-4bc2-a565-161ef349ca3e/_packaging/GraphDeveloperExperiences_Public' ProductBinPath: '$(Build.SourcesDirectory)\src\Microsoft.OpenApi\bin\$(BuildConfiguration)' REGISTRY: 'msgraphprodregistry.azurecr.io' IMAGE_NAME: 'public/openapi/hidi' @@ -88,7 +90,7 @@ extends: - + "@ | Set-Content -Path "$(Build.SourcesDirectory)/nuget.config" -Encoding UTF8 @@ -226,7 +228,16 @@ extends: inputs: targetFolder: $(Build.ArtifactStagingDirectory)/Nugets sourceFolder: $(Build.ArtifactStagingDirectory) - content: '*.nupkg' + Contents: | + *.nupkg + *.snupkg + + - task: CopyFiles@2 + displayName: 'Include version-check script in Nugets artifact' + inputs: + SourceFolder: '$(Build.SourcesDirectory)/scripts' + Contents: 'check-nuget-package-published.ps1' + TargetFolder: '$(Build.ArtifactStagingDirectory)/Nugets/scripts' # Copy repository files to be used in the deploy stage - task: CopyFiles@2 @@ -265,13 +276,46 @@ extends: pool: vmImage: ubuntu-latest steps: - - task: 1ES.PublishNuget@1 - displayName: 'NuGet push' + - task: PowerShell@2 + displayName: 'Check whether NuGet package version already published (idempotent)' + inputs: + targetType: filePath + filePath: '$(Pipeline.Workspace)/scripts/check-nuget-package-published.ps1' + arguments: '-PackageId "Microsoft.OpenApi.Hidi" -PackageDirectory "$(Pipeline.Workspace)" -NuGetServiceIndexUrl "$(privateFeedBaseUrl)/nuget/v3/index.json"' + pwsh: true + env: + FEED_ACCESS_TOKEN: $(System.AccessToken) + - task: CopyFiles@2 + displayName: 'Stage Hidi NuGet packages for ESRP release' + condition: and(succeeded(), ne(variables['nugetAlreadyPublished'], 'true')) + inputs: + SourceFolder: '$(Pipeline.Workspace)' + Contents: | + Microsoft.OpenApi.Hidi.*.nupkg + Microsoft.OpenApi.Hidi.*.snupkg + TargetFolder: '$(Pipeline.Workspace)/nuget-packages/$(NuGetOrganizationName)/hidi' + CleanTargetFolder: true + - task: EsrpRelease@14 + displayName: 'ESRP Release - Hidi NuGet' + condition: and(succeeded(), ne(variables['nugetAlreadyPublished'], 'true')) inputs: - packagesToPush: '$(Pipeline.Workspace)/Microsoft.OpenApi.Hidi.*.nupkg' - packageParentPath: '$(Pipeline.Workspace)' - nuGetFeedType: external - publishFeedCredentials: 'OpenAPI Nuget Connection' + connectedservicename: 'Federated DevX ESRP Managed Identity Connection' + usemanagedidentity: false + keyvaultname: 'akv-prod-eastus' + authcertname: 'ReferenceLibraryPrivateCert' + signcertname: 'ReferencePackagePublisherCertificate' + clientid: '65035b7f-7357-4f29-bf25-c5ee5c3949f8' + intent: 'packagedistribution' + contenttype: 'NuGet' + organizationname: '$(NuGetOrganizationName)' + contentsource: 'Folder' + folderlocation: '$(Pipeline.Workspace)/nuget-packages/$(NuGetOrganizationName)/hidi' + waitforreleasecompletion: true + owners: 'christiano@microsoft.com,ramsess@microsoft.com,gavinbarron@microsoft.com,jingjingjia@microsoft.com,peombwa@microsoft.com,treicys@microsoft.com' + approvers: 'christiano@microsoft.com,ramsess@microsoft.com,gavinbarron@microsoft.com,jingjingjia@microsoft.com,peombwa@microsoft.com,treicys@microsoft.com' + serviceendpointurl: 'https://api.esrp.microsoft.com/' + mainpublisher: 'ESRPRELPACMAN' + domaintenantid: 'cdc5aeea-15c5-4db6-b079-fcadd2505dc2' - deployment: deploy_lib condition: and(contains(variables['build.SourceBranch'], 'refs/tags/v'), succeeded()) @@ -290,21 +334,48 @@ extends: pool: vmImage: ubuntu-latest steps: - - pwsh: | - $fileNames = "$(Pipeline.Workspace)/Microsoft.OpenApi.Hidi.*.nupkg", "$(Pipeline.Workspace)/Microsoft.OpenApi.YamlReader.*.nupkg" - foreach($fileName in $fileNames) { - if(Test-Path $fileName) { - Remove-Item $fileName -Verbose - } - } - displayName: remove other nupkgs to avoid duplication - - task: 1ES.PublishNuget@1 - displayName: 'NuGet push' + - task: PowerShell@2 + displayName: 'Check whether NuGet package version already published (idempotent)' + inputs: + targetType: filePath + filePath: '$(Pipeline.Workspace)/scripts/check-nuget-package-published.ps1' + arguments: '-PackageId "Microsoft.OpenApi" -PackageDirectory "$(Pipeline.Workspace)" -NuGetServiceIndexUrl "$(privateFeedBaseUrl)/nuget/v3/index.json"' + pwsh: true + env: + FEED_ACCESS_TOKEN: $(System.AccessToken) + - task: CopyFiles@2 + displayName: 'Stage OpenAPI NuGet packages for ESRP release' + condition: and(succeeded(), ne(variables['nugetAlreadyPublished'], 'true')) + inputs: + SourceFolder: '$(Pipeline.Workspace)' + Contents: | + Microsoft.OpenApi.*.nupkg + Microsoft.OpenApi.*.snupkg + !Microsoft.OpenApi.Hidi.* + !Microsoft.OpenApi.YamlReader.* + TargetFolder: '$(Pipeline.Workspace)/nuget-packages/$(NuGetOrganizationName)/openapi' + CleanTargetFolder: true + - task: EsrpRelease@14 + displayName: 'ESRP Release - OpenAPI NuGet' + condition: and(succeeded(), ne(variables['nugetAlreadyPublished'], 'true')) inputs: - packagesToPush: '$(Pipeline.Workspace)/Microsoft.OpenApi.*.nupkg' - packageParentPath: '$(Pipeline.Workspace)' - nuGetFeedType: external - publishFeedCredentials: 'OpenAPI Nuget Connection' + connectedservicename: 'Federated DevX ESRP Managed Identity Connection' + usemanagedidentity: false + keyvaultname: 'akv-prod-eastus' + authcertname: 'ReferenceLibraryPrivateCert' + signcertname: 'ReferencePackagePublisherCertificate' + clientid: '65035b7f-7357-4f29-bf25-c5ee5c3949f8' + intent: 'packagedistribution' + contenttype: 'NuGet' + organizationname: '$(NuGetOrganizationName)' + contentsource: 'Folder' + folderlocation: '$(Pipeline.Workspace)/nuget-packages/$(NuGetOrganizationName)/openapi' + waitforreleasecompletion: true + owners: 'christiano@microsoft.com,ramsess@microsoft.com,gavinbarron@microsoft.com,jingjingjia@microsoft.com,peombwa@microsoft.com,treicys@microsoft.com' + approvers: 'christiano@microsoft.com,ramsess@microsoft.com,gavinbarron@microsoft.com,jingjingjia@microsoft.com,peombwa@microsoft.com,treicys@microsoft.com' + serviceendpointurl: 'https://api.esrp.microsoft.com/' + mainpublisher: 'ESRPRELPACMAN' + domaintenantid: 'cdc5aeea-15c5-4db6-b079-fcadd2505dc2' - deployment: deploy_yaml_reader condition: and(contains(variables['build.SourceBranch'], 'refs/tags/v'), succeeded()) @@ -323,13 +394,46 @@ extends: pool: vmImage: ubuntu-latest steps: - - task: 1ES.PublishNuget@1 - displayName: 'NuGet push' + - task: PowerShell@2 + displayName: 'Check whether NuGet package version already published (idempotent)' inputs: - packagesToPush: '$(Pipeline.Workspace)/Microsoft.OpenApi.YamlReader.*.nupkg' - packageParentPath: '$(Pipeline.Workspace)' - nuGetFeedType: external - publishFeedCredentials: 'OpenAPI Nuget Connection' + targetType: filePath + filePath: '$(Pipeline.Workspace)/scripts/check-nuget-package-published.ps1' + arguments: '-PackageId "Microsoft.OpenApi.YamlReader" -PackageDirectory "$(Pipeline.Workspace)" -NuGetServiceIndexUrl "$(privateFeedBaseUrl)/nuget/v3/index.json"' + pwsh: true + env: + FEED_ACCESS_TOKEN: $(System.AccessToken) + - task: CopyFiles@2 + displayName: 'Stage YAML reader NuGet packages for ESRP release' + condition: and(succeeded(), ne(variables['nugetAlreadyPublished'], 'true')) + inputs: + SourceFolder: '$(Pipeline.Workspace)' + Contents: | + Microsoft.OpenApi.YamlReader.*.nupkg + Microsoft.OpenApi.YamlReader.*.snupkg + TargetFolder: '$(Pipeline.Workspace)/nuget-packages/$(NuGetOrganizationName)/yaml-reader' + CleanTargetFolder: true + - task: EsrpRelease@14 + displayName: 'ESRP Release - YAML reader NuGet' + condition: and(succeeded(), ne(variables['nugetAlreadyPublished'], 'true')) + inputs: + connectedservicename: 'Federated DevX ESRP Managed Identity Connection' + usemanagedidentity: false + keyvaultname: 'akv-prod-eastus' + authcertname: 'ReferenceLibraryPrivateCert' + signcertname: 'ReferencePackagePublisherCertificate' + clientid: '65035b7f-7357-4f29-bf25-c5ee5c3949f8' + intent: 'packagedistribution' + contenttype: 'NuGet' + organizationname: '$(NuGetOrganizationName)' + contentsource: 'Folder' + folderlocation: '$(Pipeline.Workspace)/nuget-packages/$(NuGetOrganizationName)/yaml-reader' + waitforreleasecompletion: true + owners: 'christiano@microsoft.com,ramsess@microsoft.com,gavinbarron@microsoft.com,jingjingjia@microsoft.com,peombwa@microsoft.com,treicys@microsoft.com' + approvers: 'christiano@microsoft.com,ramsess@microsoft.com,gavinbarron@microsoft.com,jingjingjia@microsoft.com,peombwa@microsoft.com,treicys@microsoft.com' + serviceendpointurl: 'https://api.esrp.microsoft.com/' + mainpublisher: 'ESRPRELPACMAN' + domaintenantid: 'cdc5aeea-15c5-4db6-b079-fcadd2505dc2' - deployment: create_github_release condition: and(contains(variables['build.SourceBranch'], 'refs/tags/v'), succeeded()) @@ -459,7 +563,33 @@ extends: displayName: 'Get current date' name: setdate condition: eq(variables['Build.SourceBranch'], variables['PREVIEW_BRANCH']) - + + # Keep feed credentials out of the Docker build context and image layers. + - pwsh: | + if ([string]::IsNullOrWhiteSpace($env:FEED_ACCESS_TOKEN)) { + throw "No Azure Artifacts access token available for the Docker build." + } + $feedAccessToken = [System.Security.SecurityElement]::Escape($env:FEED_ACCESS_TOKEN) + @" + + + + + + + + + + + + + + + "@ | Set-Content -Path "$(Agent.TempDirectory)/hidi-docker.nuget.config" -Encoding UTF8 + displayName: 'Create Docker NuGet config (central feed)' + env: + FEED_ACCESS_TOKEN: $(System.AccessToken) + - script: | docker run --privileged --rm msgraphprodregistry.azurecr.io/tonistiigi/binfmt --install all displayName: "Enable multi-platform builds" @@ -478,6 +608,7 @@ extends: # Using quotes around tags to prevent flag interpretation docker buildx build \ --platform linux/amd64,linux/arm64/v8 \ + --secret id=nuget_config,src="$(Agent.TempDirectory)/hidi-docker.nuget.config" \ --push \ -t "$(REGISTRY)/$(IMAGE_NAME):nightly" \ -t "$(REGISTRY)/$(IMAGE_NAME):${VERSION}.${BUILDDATE}${RUNNUMBER}" \ @@ -490,6 +621,7 @@ extends: echo "Building Docker image for release..." docker buildx build\ --platform linux/amd64,linux/arm64/v8 \ + --secret id=nuget_config,src="$(Agent.TempDirectory)/hidi-docker.nuget.config" \ --push \ -t "$(REGISTRY)/$(IMAGE_NAME):latest" \ -t "$(REGISTRY)/$(IMAGE_NAME):${VERSION}" \ @@ -497,6 +629,14 @@ extends: displayName: 'Build and Push Release Image' condition: contains(variables['Build.SourceBranch'], 'refs/tags/v') + - pwsh: | + $configPath = "$(Agent.TempDirectory)/hidi-docker.nuget.config" + if (Test-Path $configPath) { + Remove-Item $configPath -Force + } + displayName: 'Remove Docker NuGet config' + condition: always() + # once the nuget has been released, fill this form to get the public documentation updated. # https://dev.azure.com/msft-skilling/Content/_workitems/create/User%20Story?templateId=39fb91e3-64a2-4c8a-83db-b2bdf3603dd3&ownerId=c4a28f90-17ae-4384-b514-7273392b082b # https://learn.microsoft.com/en-us/dotnet/api/microsoft.openapi diff --git a/Dockerfile b/Dockerfile index 46cb00637..4e932b975 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,9 @@ COPY ./src ./hidi/src COPY ./Directory.Build.props ./hidi/Directory.Build.props COPY ./README.md ./hidi/README.md WORKDIR /app/hidi -RUN dotnet publish ./src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj -c Release +# CI supplies the private feed config as a secret; local builds use default NuGet sources. +RUN --mount=type=secret,id=nuget_config,target=/app/hidi/NuGet.Config \ + dotnet publish ./src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj -c Release FROM mcr.microsoft.com/dotnet/runtime:8.0-jammy-chiseled AS runtime WORKDIR /app diff --git a/scripts/check-nuget-package-published.ps1 b/scripts/check-nuget-package-published.ps1 new file mode 100644 index 000000000..84f45419d --- /dev/null +++ b/scripts/check-nuget-package-published.ps1 @@ -0,0 +1,84 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +<# +.SYNOPSIS +Checks whether a NuGet artifact's version exists in an authenticated Azure Artifacts feed. +.DESCRIPTION +Resolves the package content endpoint from the private feed's NuGet v3 service index. +Sets nugetAlreadyPublished for the ESRP release steps; only a missing package or version +permits publishing. Feed authentication and other lookup failures fail the step. +#> +[CmdletBinding()] +param( + [Parameter(Mandatory = $true)] + [string]$PackageDirectory, + [Parameter(Mandatory = $true)] + [string]$PackageId, + [Parameter(Mandatory = $true)] + [string]$NuGetServiceIndexUrl, + [string]$FeedAccessToken = $env:FEED_ACCESS_TOKEN +) + +$ErrorActionPreference = 'Stop' + +function Assert-PrivateFeedUrl { + param([string]$Url) + + $uri = [uri]$Url + if (-not $uri.IsAbsoluteUri -or $uri.Scheme -ne 'https' -or + ($uri.Host -ne 'pkgs.dev.azure.com' -and -not $uri.Host.EndsWith('.pkgs.visualstudio.com'))) { + throw "NuGet lookups must use an HTTPS Azure Artifacts feed: $Url" + } +} + +Assert-PrivateFeedUrl -Url $NuGetServiceIndexUrl +if ([string]::IsNullOrWhiteSpace($FeedAccessToken)) { + throw 'FEED_ACCESS_TOKEN is required to query the private NuGet feed.' +} + +$packagePattern = '^' + [regex]::Escape($PackageId) + '\.(\d[\w\.\-]*)\.nupkg$' +$packages = @(Get-ChildItem -Path $PackageDirectory -File -Filter "$PackageId.*.nupkg" | + Where-Object { $_.Name -match $packagePattern }) +if ($packages.Count -ne 1) { + throw "Expected exactly one $PackageId nupkg to publish; found $($packages.Count)." +} +$version = [regex]::Match($packages[0].Name, $packagePattern, 'IgnoreCase').Groups[1].Value +$id = $PackageId.ToLowerInvariant() +$credentials = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes("AzureDevOps:$FeedAccessToken")) +$headers = @{ + 'Authorization' = "Basic $credentials" + 'User-Agent' = 'openapi-azdo-pipeline' +} + +$index = Invoke-RestMethod -Uri $NuGetServiceIndexUrl -Headers $headers -MaximumRedirection 0 +$resource = $index.resources | Where-Object { $_.'@type' -eq 'PackageBaseAddress/3.0.0' } | Select-Object -First 1 +if ([string]::IsNullOrWhiteSpace($resource.'@id')) { + throw "No PackageBaseAddress resource found in the NuGet service index at $NuGetServiceIndexUrl" +} +$uri = "$($resource.'@id'.TrimEnd('/'))/$id/index.json" +Assert-PrivateFeedUrl -Url $uri + +try { + $response = Invoke-RestMethod -Uri $uri -Headers $headers -MaximumRedirection 0 + if ($null -eq $response.versions) { + throw "No versions returned for NuGet $id by the private feed." + } + $alreadyPublished = $response.versions -contains $version +} +catch { + if ([int]$_.Exception.Response.StatusCode -eq 404) { + $alreadyPublished = $false + } + else { + throw + } +} + +if ($alreadyPublished) { + Write-Host "NuGet $id $version already present in the private feed; skipping ESRP release (idempotent re-run)." +} +else { + Write-Host "NuGet $id $version not found in the private feed; will publish via ESRP." +} +Write-Host "##vso[task.setvariable variable=nugetAlreadyPublished]$($alreadyPublished.ToString().ToLowerInvariant())" From 01d472995b3c466feb5bbf61e303bcd7752da16a Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Fri, 9 Oct 2026 10:28:57 -0700 Subject: [PATCH 944/984] fix: components-key validation timeouts under load (#3108) * Initial plan * fix(library): avoid components key validation timeouts under load Co-authored-by: baywet <7905502+baywet@users.noreply.github.com> * fix(library): use conditional regex fallback for older frameworks Co-authored-by: baywet <7905502+baywet@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: baywet <7905502+baywet@users.noreply.github.com> --- agents.md | 7 +++ .../Expressions/CompositeExpression.cs | 19 +++++- .../Rules/OpenApiComponentsRules.cs | 23 +++++-- .../Expressions/RuntimeExpressionTests.cs | 22 +++++++ .../OpenApiComponentsValidationTests.cs | 63 ++++++++++++++++++- 5 files changed, 125 insertions(+), 9 deletions(-) create mode 100644 agents.md diff --git a/agents.md b/agents.md new file mode 100644 index 000000000..abeed736e --- /dev/null +++ b/agents.md @@ -0,0 +1,7 @@ +# Regex handling + +- Analyze regex patterns for matching complexity and excessive backtracking, including on long and near-matching inputs. Prefer equivalent patterns with less backtracking when available, while preserving matching semantics and target-framework compatibility. +- For fixed patterns on modern targets, use source-generated regexes with explicit match timeouts (`GeneratedRegex` under `NET8_0_OR_GREATER`). +- Use conditional compilation to provide a regular `Regex` with the same pattern and an explicit match timeout for older targets. Do not duplicate regex validation with a manually maintained character scanner. +- Older-runtime regex matching may still time out under load because timeouts use wall-clock time. If consumers encounter this limitation, recommend upgrading to a modern runtime that uses the source-generated implementation. +- Keep shared patterns in constants and reference those constants in validation diagnostics and tests. diff --git a/src/Microsoft.OpenApi/Expressions/CompositeExpression.cs b/src/Microsoft.OpenApi/Expressions/CompositeExpression.cs index cac554318..db2a97caf 100644 --- a/src/Microsoft.OpenApi/Expressions/CompositeExpression.cs +++ b/src/Microsoft.OpenApi/Expressions/CompositeExpression.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. +using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; @@ -10,10 +11,17 @@ namespace Microsoft.OpenApi /// /// String literal with embedded expressions /// - public class CompositeExpression : RuntimeExpression + public partial class CompositeExpression : RuntimeExpression { private readonly string template; - private readonly Regex expressionPattern = new(@"{(?\$[^}]*)"); + private const string ExpressionPattern = @"{(?\$[^}]*)"; + +#if NET8_0_OR_GREATER + [GeneratedRegex(ExpressionPattern, RegexOptions.None, matchTimeoutMilliseconds: 100)] + private static partial Regex ExpressionRegex(); +#else + private static readonly Regex ExpressionRegex = new(ExpressionPattern, RegexOptions.None, TimeSpan.FromMilliseconds(100)); +#endif /// /// Expressions embedded into string literal @@ -24,12 +32,17 @@ public class CompositeExpression : RuntimeExpression /// Create a composite expression from a string literal with an embedded expression /// /// + /// Extracting embedded expressions exceeds the regex match timeout. public CompositeExpression(string expression) { template = expression; // Extract subexpressions and convert to RuntimeExpressions - var matches = expressionPattern.Matches(expression); +#if NET8_0_OR_GREATER + var matches = ExpressionRegex().Matches(expression); +#else + var matches = ExpressionRegex.Matches(expression); +#endif foreach (var item in matches.Cast()) { diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiComponentsRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiComponentsRules.cs index e3c6e1b4f..7473bce91 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiComponentsRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiComponentsRules.cs @@ -11,12 +11,19 @@ namespace Microsoft.OpenApi /// The validation rules for . /// [OpenApiRule] - public static class OpenApiComponentsRules + public static partial class OpenApiComponentsRules { /// - /// The key regex. + /// The key regex pattern. /// - internal static readonly Regex KeyRegex = new(@"^[a-zA-Z0-9\.\-_]+$", RegexOptions.None, TimeSpan.FromMilliseconds(100)); + internal const string KeyPattern = @"^[a-zA-Z0-9\.\-_]+$"; + +#if NET8_0_OR_GREATER + [GeneratedRegex(KeyPattern, RegexOptions.None, matchTimeoutMilliseconds: 100)] + private static partial Regex KeyRegex(); +#else + private static readonly Regex KeyRegex = new(KeyPattern, RegexOptions.None, TimeSpan.FromMilliseconds(100)); +#endif /// /// All the fixed fields declared above are objects @@ -54,12 +61,18 @@ private static void ValidateKeys(IValidationContext context, IEnumerable foreach (var key in keys) { - if (!KeyRegex.IsMatch(key)) +#if NET8_0_OR_GREATER + var isValidKey = KeyRegex().IsMatch(key); +#else + var isValidKey = KeyRegex.IsMatch(key); +#endif + if (!isValidKey) { context.CreateError(nameof(KeyMustBeRegularExpression), - string.Format(SRResource.Validation_ComponentsKeyMustMatchRegularExpr, key, component, KeyRegex.ToString())); + string.Format(SRResource.Validation_ComponentsKeyMustMatchRegularExpr, key, component, KeyPattern)); } } } + } } diff --git a/test/Microsoft.OpenApi.Tests/Expressions/RuntimeExpressionTests.cs b/test/Microsoft.OpenApi.Tests/Expressions/RuntimeExpressionTests.cs index 08a1debc0..91509184b 100644 --- a/test/Microsoft.OpenApi.Tests/Expressions/RuntimeExpressionTests.cs +++ b/test/Microsoft.OpenApi.Tests/Expressions/RuntimeExpressionTests.cs @@ -145,6 +145,28 @@ public void BuildRuntimeExpressionTwiceCreatesNewEquivalentInstances(string expr Assert.Equal(runtimeExpression1, runtimeExpression2); } + [Fact] + public void CompositeRuntimeExpressionPreservesMultilineCaptures() + { + const string expression = "prefix {$request.header.foo\nbar} {$url} suffix"; + + var composite = Assert.IsType(RuntimeExpression.Build(expression)); + + Assert.Equal(expression, composite.Expression); + Assert.Equal(new[] { "$request.header.foo\nbar", "$url" }, + composite.ContainedExpressions.Select(static item => item.Expression)); + } + + [Fact] + public void CompositeRuntimeExpressionPreservesUnterminatedCapture() + { + const string expression = "prefix {$url"; + + var composite = Assert.IsType(RuntimeExpression.Build(expression)); + + Assert.IsType(Assert.Single(composite.ContainedExpressions)); + } + [Fact] public void CompositeRuntimeExpressionContainsExpression() { diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiComponentsValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiComponentsValidationTests.cs index 68f89a2a2..8993c17a5 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiComponentsValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiComponentsValidationTests.cs @@ -2,7 +2,11 @@ // Licensed under the MIT license. using System.Collections.Generic; +using System.IO; using System.Linq; +using System.Text; +using System.Text.Json; +using System.Threading.Tasks; using Xunit; namespace Microsoft.OpenApi.Validations.Tests @@ -32,8 +36,65 @@ public void ValidateKeyMustMatchRegularExpressionInComponents() Assert.False(result); Assert.NotNull(errors); var error = Assert.Single(errors); - Assert.Equal(string.Format(SRResource.Validation_ComponentsKeyMustMatchRegularExpr, key, "responses", OpenApiComponentsRules.KeyRegex.ToString()), + Assert.Equal(string.Format(SRResource.Validation_ComponentsKeyMustMatchRegularExpr, key, "responses", OpenApiComponentsRules.KeyPattern), error.Message); } + + [Theory] + [InlineData("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_", true)] + [InlineData("", false)] + [InlineData("a b", false)] + [InlineData("a/b", false)] + [InlineData("é", false)] + [InlineData("12", false)] + [InlineData("a\n", true)] + [InlineData("\n", false)] + [InlineData("a\n\n", false)] + [InlineData("a\r\n", false)] + [InlineData("a\nb", false)] + [InlineData("a\0", false)] + public void ValidateComponentKeyPreservesRegexBehavior(string key, bool isValid) + { + var components = new OpenApiComponents + { + Schemas = new Dictionary + { + { key, new OpenApiSchema() } + } + }; + + var rules = new ValidationRuleSet(); + rules.Add(typeof(OpenApiComponents), OpenApiComponentsRules.KeyMustBeRegularExpression); + var errors = components.Validate(rules); + + Assert.Equal(isValid, !errors.Any()); + } + + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task LoadAsyncValidatesLongComponentKeys(bool isValid) + { + var key = new string('a', 1_000_000) + (isValid ? string.Empty : "!"); + var json = """ + {"openapi":"3.1.0","info":{"title":"Test","version":"1.0"},"paths":{},"components":{"schemas":{ + """ + JsonSerializer.Serialize(key) + ":{\"type\":\"string\"}}}}"; + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(json)); + + var result = await OpenApiDocument.LoadAsync(stream, cancellationToken: TestContext.Current.CancellationToken); + + Assert.NotNull(result.Document); + Assert.NotNull(result.Diagnostic); + if (isValid) + { + Assert.Empty(result.Diagnostic.Errors); + } + else + { + var error = Assert.Single(result.Diagnostic.Errors); + Assert.Equal(string.Format(SRResource.Validation_ComponentsKeyMustMatchRegularExpr, + key, "schemas", OpenApiComponentsRules.KeyPattern), error.Message); + } + } } } From 1ff69b41d7e4bf4ccead9743b4ddb6a2b30041d9 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Fri, 9 Oct 2026 13:44:42 -0400 Subject: [PATCH 945/984] ci: ports additional validation back from yoko (#3113) --- scripts/check-nuget-package-published.ps1 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/check-nuget-package-published.ps1 b/scripts/check-nuget-package-published.ps1 index 84f45419d..0f31961ec 100644 --- a/scripts/check-nuget-package-published.ps1 +++ b/scripts/check-nuget-package-published.ps1 @@ -64,6 +64,11 @@ try { if ($null -eq $response.versions) { throw "No versions returned for NuGet $id by the private feed." } + if ($response.versions -isnot [array] -or @($response.versions | Where-Object { + $_ -isnot [string] -or $_ -notmatch '^\d[\w\.\-]*$' + }).Count -gt 0) { + throw "Invalid version list returned for NuGet $id by the private feed." + } $alreadyPublished = $response.versions -contains $version } catch { @@ -81,4 +86,4 @@ if ($alreadyPublished) { else { Write-Host "NuGet $id $version not found in the private feed; will publish via ESRP." } -Write-Host "##vso[task.setvariable variable=nugetAlreadyPublished]$($alreadyPublished.ToString().ToLowerInvariant())" +Write-Host "##vso[task.setvariable variable=nugetAlreadyPublished]$($alreadyPublished.ToString().ToLowerInvariant())" \ No newline at end of file From be0f4bd6c34ce76387614fe610f5082a4803668d Mon Sep 17 00:00:00 2001 From: Gavin Barron Date: Tue, 13 Oct 2026 12:29:13 -0700 Subject: [PATCH 946/984] refactor(hidi): remove migrated main tool resources Remove migrated Hidi source, tests, fixtures and publishing resources after verified destination handoff. Preserve OpenAPI core/YAML build, signing and publishing infrastructure. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c631d217-9378-4cee-8c7e-761043ff3ae5 --- .azure-pipelines/ci-build.yml | 261 +- .github/workflows/codeql-analysis.yml | 3 +- .vscode/launch.json | 18 - .vscode/settings.json | 1 - .vscode/tasks.json | 14 - CONTRIBUTING.md | 4 +- Dockerfile | 25 - Microsoft.OpenApi.slnx | 2 - README.md | 8 +- build.cmd | 7 - build.sh | 7 - install-tool.ps1 | 7 - src/Microsoft.OpenApi.Hidi/CsdlFilter.xslt | 22 - .../Extensions/CommandExtensions.cs | 19 - .../Extensions/OpenApiExtensibleExtensions.cs | 23 - .../Extensions/StringExtensions.cs | 46 - .../Formatters/PowerShellFormatter.cs | 251 - .../Handlers/PluginCommandHandler.cs | 53 - .../Handlers/ShowCommandHandler.cs | 53 - .../Handlers/TransformCommandHandler.cs | 53 - .../Handlers/ValidateCommandHandler.cs | 53 - src/Microsoft.OpenApi.Hidi/Logger.cs | 28 - .../Microsoft.OpenApi.Hidi.csproj | 67 - src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 818 - .../OpenApiSpecVersionHelper.cs | 46 - .../Options/CommandOptions.cs | 144 - .../Options/FilterOptions.cs | 13 - .../Options/HidiOptions.cs | 65 - src/Microsoft.OpenApi.Hidi/Program.cs | 60 - src/Microsoft.OpenApi.Hidi/StatsVisitor.cs | 86 - .../Utilities/SettingsUtilities.cs | 39 - src/Microsoft.OpenApi.Hidi/readme.md | 148 - .../Properties/AssemblyInfo.cs | 3 - .../Formatters/PowerShellFormatterTests.cs | 192 - .../Microsoft.OpenApi.Hidi.Tests.csproj | 46 - .../OpenApiSpecVersionHelperTests.cs | 31 - .../Services/OpenApiFilterServiceTests.cs | 371 - .../Services/OpenApiServiceTests.cs | 380 - .../StatsVisitorTests.cs | 110 - .../Utilities/SettingsUtilitiesTests.cs | 44 - .../UtilityFiles/InvalidSampleOpenApi.yml | 19 - .../UtilityFiles/OpenApiDocumentMock.cs | 689 - .../UtilityFiles/SampleOpenApi.yml | 22 - .../UtilityFiles/Todo.xml | 21 - .../UtilityFiles/appsettingstest.json | 21 - .../docWithReusableHeadersAndExamples.yaml | 85 - .../UtilityFiles/exampleapimanifest.json | 27 - .../examplepowershellsettings.json | 22 - .../UtilityFiles/postmanCollection_ver1.json | 102 - .../UtilityFiles/postmanCollection_ver2.json | 23698 ---------------- .../UtilityFiles/postmanCollection_ver3.json | 1382 - .../UtilityFiles/postmanCollection_ver4.json | 145 - .../Microsoft.OpenApi.Tests.csproj | 1 - 53 files changed, 8 insertions(+), 29847 deletions(-) delete mode 100644 Dockerfile delete mode 100644 install-tool.ps1 delete mode 100644 src/Microsoft.OpenApi.Hidi/CsdlFilter.xslt delete mode 100644 src/Microsoft.OpenApi.Hidi/Extensions/CommandExtensions.cs delete mode 100644 src/Microsoft.OpenApi.Hidi/Extensions/OpenApiExtensibleExtensions.cs delete mode 100644 src/Microsoft.OpenApi.Hidi/Extensions/StringExtensions.cs delete mode 100644 src/Microsoft.OpenApi.Hidi/Formatters/PowerShellFormatter.cs delete mode 100644 src/Microsoft.OpenApi.Hidi/Handlers/PluginCommandHandler.cs delete mode 100644 src/Microsoft.OpenApi.Hidi/Handlers/ShowCommandHandler.cs delete mode 100644 src/Microsoft.OpenApi.Hidi/Handlers/TransformCommandHandler.cs delete mode 100644 src/Microsoft.OpenApi.Hidi/Handlers/ValidateCommandHandler.cs delete mode 100644 src/Microsoft.OpenApi.Hidi/Logger.cs delete mode 100644 src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj delete mode 100644 src/Microsoft.OpenApi.Hidi/OpenApiService.cs delete mode 100644 src/Microsoft.OpenApi.Hidi/OpenApiSpecVersionHelper.cs delete mode 100644 src/Microsoft.OpenApi.Hidi/Options/CommandOptions.cs delete mode 100644 src/Microsoft.OpenApi.Hidi/Options/FilterOptions.cs delete mode 100644 src/Microsoft.OpenApi.Hidi/Options/HidiOptions.cs delete mode 100644 src/Microsoft.OpenApi.Hidi/Program.cs delete mode 100644 src/Microsoft.OpenApi.Hidi/StatsVisitor.cs delete mode 100644 src/Microsoft.OpenApi.Hidi/Utilities/SettingsUtilities.cs delete mode 100644 src/Microsoft.OpenApi.Hidi/readme.md delete mode 100644 test/Microsoft.OpenApi.Hidi.Tests/Formatters/PowerShellFormatterTests.cs delete mode 100644 test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj delete mode 100644 test/Microsoft.OpenApi.Hidi.Tests/OpenApiSpecVersionHelperTests.cs delete mode 100644 test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs delete mode 100644 test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs delete mode 100644 test/Microsoft.OpenApi.Hidi.Tests/StatsVisitorTests.cs delete mode 100644 test/Microsoft.OpenApi.Hidi.Tests/Utilities/SettingsUtilitiesTests.cs delete mode 100644 test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/InvalidSampleOpenApi.yml delete mode 100644 test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/OpenApiDocumentMock.cs delete mode 100644 test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/SampleOpenApi.yml delete mode 100644 test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/Todo.xml delete mode 100644 test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/appsettingstest.json delete mode 100644 test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/docWithReusableHeadersAndExamples.yaml delete mode 100644 test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/exampleapimanifest.json delete mode 100644 test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/examplepowershellsettings.json delete mode 100644 test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/postmanCollection_ver1.json delete mode 100644 test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/postmanCollection_ver2.json delete mode 100644 test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/postmanCollection_ver3.json delete mode 100644 test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/postmanCollection_ver4.json diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index 5e8a40e98..1281acf0a 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -24,9 +24,6 @@ variables: NuGetOrganizationName: 'openapinet' privateFeedBaseUrl: 'https://microsoftgraph.pkgs.visualstudio.com/0985d294-5762-4bc2-a565-161ef349ca3e/_packaging/GraphDeveloperExperiences_Public' ProductBinPath: '$(Build.SourcesDirectory)\src\Microsoft.OpenApi\bin\$(BuildConfiguration)' - REGISTRY: 'msgraphprodregistry.azurecr.io' - IMAGE_NAME: 'public/openapi/hidi' - PREVIEW_BRANCH: 'refs/heads/main' resources: repositories: @@ -53,10 +50,6 @@ extends: displayName: 'Publish Artifact: Nugets' artifactName: Nugets targetPath: '$(Build.ArtifactStagingDirectory)/Nugets' - - output: pipelineArtifact - displayName: 'Publish Artifact: RepoFiles' - artifactName: RepoFiles - targetPath: '$(Build.ArtifactStagingDirectory)/RepoFiles' steps: - task: UseDotNet@2 displayName: 'Use .NET 6' @@ -175,10 +168,6 @@ extends: - pwsh: dotnet pack $(Build.SourcesDirectory)/src/Microsoft.OpenApi.YamlReader/Microsoft.OpenApi.YamlReader.csproj -o $(Build.ArtifactStagingDirectory) --configuration $(BuildConfiguration) --no-build --include-symbols --include-source /p:SymbolPackageFormat=snupkg displayName: 'pack YamlReader' - # Pack hidi - - pwsh: dotnet pack $(Build.SourcesDirectory)/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj -o $(Build.ArtifactStagingDirectory) --configuration $(BuildConfiguration) --no-build --include-symbols --include-source /p:SymbolPackageFormat=snupkg - displayName: 'pack Hidi' - - task: EsrpCodeSigning@6 displayName: 'ESRP CodeSigning Nuget Packages' inputs: @@ -213,16 +202,6 @@ extends: MaxRetryAttempts: '5' PendingAnalysisWaitTimeoutMinutes: '5' - # publish hidi as an .exe - - task: DotNetCoreCLI@2 - displayName: publish Hidi as executable - inputs: - command: 'publish' - arguments: -c Release --runtime win-x64 -p:RestoreConfigFile=$(Build.SourcesDirectory)\nuget.config /p:PublishSingleFile=true /p:PackAsTool=false --self-contained --output $(Build.ArtifactStagingDirectory)/Microsoft.OpenApi.Hidi - projects: 'src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj' - publishWebProjects: False - zipAfterPublish: false - - task: CopyFiles@2 displayName: Prepare staging folder for upload inputs: @@ -239,84 +218,14 @@ extends: Contents: 'check-nuget-package-published.ps1' TargetFolder: '$(Build.ArtifactStagingDirectory)/Nugets/scripts' - # Copy repository files to be used in the deploy stage - - task: CopyFiles@2 - displayName: 'Copy repository files for deploy stage' - inputs: - SourceFolder: '$(Build.SourcesDirectory)' - Contents: | - **/* - !**/bin/** - !**/obj/** - !**/.git/** - TargetFolder: '$(Build.ArtifactStagingDirectory)/RepoFiles' - - stage: deploy - condition: and(or(contains(variables['Build.SourceBranch'], 'refs/tags/v'), eq(variables['Build.SourceBranch'], variables['PREVIEW_BRANCH'])), succeeded()) + condition: and(contains(variables['Build.SourceBranch'], 'refs/tags/v'), succeeded()) dependsOn: build pool: name: Azure-Pipelines-1ESPT-ExDShared os: linux image: ubuntu-latest jobs: - - deployment: deploy_hidi - condition: and(contains(variables['build.SourceBranch'], 'refs/tags/v'), succeeded()) - templateContext: - type: releaseJob - isProduction: true - inputs: - - input: pipelineArtifact - artifactName: Nugets - targetPath: '$(Pipeline.Workspace)' - dependsOn: [] - environment: nuget-org - strategy: - runOnce: - deploy: - pool: - vmImage: ubuntu-latest - steps: - - task: PowerShell@2 - displayName: 'Check whether NuGet package version already published (idempotent)' - inputs: - targetType: filePath - filePath: '$(Pipeline.Workspace)/scripts/check-nuget-package-published.ps1' - arguments: '-PackageId "Microsoft.OpenApi.Hidi" -PackageDirectory "$(Pipeline.Workspace)" -NuGetServiceIndexUrl "$(privateFeedBaseUrl)/nuget/v3/index.json"' - pwsh: true - env: - FEED_ACCESS_TOKEN: $(System.AccessToken) - - task: CopyFiles@2 - displayName: 'Stage Hidi NuGet packages for ESRP release' - condition: and(succeeded(), ne(variables['nugetAlreadyPublished'], 'true')) - inputs: - SourceFolder: '$(Pipeline.Workspace)' - Contents: | - Microsoft.OpenApi.Hidi.*.nupkg - Microsoft.OpenApi.Hidi.*.snupkg - TargetFolder: '$(Pipeline.Workspace)/nuget-packages/$(NuGetOrganizationName)/hidi' - CleanTargetFolder: true - - task: EsrpRelease@14 - displayName: 'ESRP Release - Hidi NuGet' - condition: and(succeeded(), ne(variables['nugetAlreadyPublished'], 'true')) - inputs: - connectedservicename: 'Federated DevX ESRP Managed Identity Connection' - usemanagedidentity: false - keyvaultname: 'akv-prod-eastus' - authcertname: 'ReferenceLibraryPrivateCert' - signcertname: 'ReferencePackagePublisherCertificate' - clientid: '65035b7f-7357-4f29-bf25-c5ee5c3949f8' - intent: 'packagedistribution' - contenttype: 'NuGet' - organizationname: '$(NuGetOrganizationName)' - contentsource: 'Folder' - folderlocation: '$(Pipeline.Workspace)/nuget-packages/$(NuGetOrganizationName)/hidi' - waitforreleasecompletion: true - owners: 'christiano@microsoft.com,ramsess@microsoft.com,gavinbarron@microsoft.com,jingjingjia@microsoft.com,peombwa@microsoft.com,treicys@microsoft.com' - approvers: 'christiano@microsoft.com,ramsess@microsoft.com,gavinbarron@microsoft.com,jingjingjia@microsoft.com,peombwa@microsoft.com,treicys@microsoft.com' - serviceendpointurl: 'https://api.esrp.microsoft.com/' - mainpublisher: 'ESRPRELPACMAN' - domaintenantid: 'cdc5aeea-15c5-4db6-b079-fcadd2505dc2' - - deployment: deploy_lib condition: and(contains(variables['build.SourceBranch'], 'refs/tags/v'), succeeded()) templateContext: @@ -351,7 +260,6 @@ extends: Contents: | Microsoft.OpenApi.*.nupkg Microsoft.OpenApi.*.snupkg - !Microsoft.OpenApi.Hidi.* !Microsoft.OpenApi.YamlReader.* TargetFolder: '$(Pipeline.Workspace)/nuget-packages/$(NuGetOrganizationName)/openapi' CleanTargetFolder: true @@ -468,175 +376,8 @@ extends: tagSource: userSpecifiedTag tag: 'v$(artifactVersion)' releaseNotesSource: inline - assets: '$(Pipeline.Workspace)\**\*.exe' addChangeLog: false - - deployment: deploy_docker_image - environment: docker-images-deploy - templateContext: - type: releaseJob - isProduction: true - inputs: - - input: pipelineArtifact - artifactName: RepoFiles - targetPath: '$(Pipeline.Workspace)' - strategy: - runOnce: - deploy: - pool: - vmImage: 'ubuntu-latest' - steps: - - task: AzureCLI@2 - displayName: 'Login to Azure Container Registry' - inputs: - azureSubscription: 'ACR Images Push Service Connection' - scriptType: bash - scriptLocation: inlineScript - inlineScript: | - az acr login --name $(REGISTRY) - - - pwsh: | - $content = [XML](Get-Content $(Pipeline.Workspace)/Directory.Build.props) - Write-Host "XML loaded, finding version..." - - # Handle PropertyGroup as either a single element or array - $version = $null - if ($content.Project.PropertyGroup -is [array]) { - Write-Host "PropertyGroup is an array, checking each entry..." - foreach ($pg in $content.Project.PropertyGroup) { - if ($pg.Version) { - $version = $pg.Version.ToString().Trim() - Write-Host "Found version in PropertyGroup array: $version" - break - } - } - } else { - # Single PropertyGroup - $version = $content.Project.PropertyGroup.Version - if ($version) { - $version = $version.ToString().Trim() - Write-Host "Found version in PropertyGroup: $version" - } - } - - if (-not $version) { - Write-Host "##vso[task.logissue type=error]Version not found in Directory.Build.props" - exit 1 - } - - Write-Host "Version found: $version" - Write-Host "##vso[task.setvariable variable=version;isoutput=true]$version" - Write-Host "##vso[task.setvariable variable=VERSION]$version" - displayName: 'Get version from csproj' - name: getversion - - - bash: | - # Debug output to verify version variable - echo "Version from previous step: $VERSION" - displayName: 'Verify version variable' - - - bash: | - echo "Build Number: $(Build.BuildNumber)" - # Extract the last 3 characters for the run number - runnumber=$(echo "$(Build.BuildNumber)" | grep -o '[0-9]\+$') - echo "Extracted Run Number: $runnumber" - - # If extraction fails, set a default - if [ -z "$runnumber" ]; then - echo "Extraction failed, using default value" - runnumber=$(date +"%S%N" | cut -c1-3) - echo "Generated fallback run number: $runnumber" - fi - - # Set the variable for later steps - echo "##vso[task.setvariable variable=RUNNUMBER]$runnumber" - echo "##vso[task.setvariable variable=RUNNUMBER;isOutput=true]$runnumber" - displayName: 'Get truncated run number' - name: getrunnumber - condition: eq(variables['Build.SourceBranch'], variables['PREVIEW_BRANCH']) - - - bash: | - date=$(date +'%Y%m%d') - echo "Date value: $date" - echo "##vso[task.setvariable variable=BUILDDATE;isOutput=true]$date" - echo "##vso[task.setvariable variable=BUILDDATE]$date" - displayName: 'Get current date' - name: setdate - condition: eq(variables['Build.SourceBranch'], variables['PREVIEW_BRANCH']) - - # Keep feed credentials out of the Docker build context and image layers. - - pwsh: | - if ([string]::IsNullOrWhiteSpace($env:FEED_ACCESS_TOKEN)) { - throw "No Azure Artifacts access token available for the Docker build." - } - $feedAccessToken = [System.Security.SecurityElement]::Escape($env:FEED_ACCESS_TOKEN) - @" - - - - - - - - - - - - - - - "@ | Set-Content -Path "$(Agent.TempDirectory)/hidi-docker.nuget.config" -Encoding UTF8 - displayName: 'Create Docker NuGet config (central feed)' - env: - FEED_ACCESS_TOKEN: $(System.AccessToken) - - - script: | - docker run --privileged --rm msgraphprodregistry.azurecr.io/tonistiigi/binfmt --install all - displayName: "Enable multi-platform builds" - - - script: | - docker buildx create --use --name mybuilder - displayName: "Set up Docker BuildX" - - - script: | - docker buildx inspect --bootstrap - displayName: "Ensure BuildX is working" - - - bash: | - echo "Building Docker image..." - echo "Using build date: ${BUILDDATE}" - # Using quotes around tags to prevent flag interpretation - docker buildx build \ - --platform linux/amd64,linux/arm64/v8 \ - --secret id=nuget_config,src="$(Agent.TempDirectory)/hidi-docker.nuget.config" \ - --push \ - -t "$(REGISTRY)/$(IMAGE_NAME):nightly" \ - -t "$(REGISTRY)/$(IMAGE_NAME):${VERSION}.${BUILDDATE}${RUNNUMBER}" \ - "$(Pipeline.Workspace)" - - displayName: 'Build and Push Nightly Image' - condition: eq(variables['Build.SourceBranch'], variables['PREVIEW_BRANCH']) - - - bash: | - echo "Building Docker image for release..." - docker buildx build\ - --platform linux/amd64,linux/arm64/v8 \ - --secret id=nuget_config,src="$(Agent.TempDirectory)/hidi-docker.nuget.config" \ - --push \ - -t "$(REGISTRY)/$(IMAGE_NAME):latest" \ - -t "$(REGISTRY)/$(IMAGE_NAME):${VERSION}" \ - "$(Pipeline.Workspace)" - displayName: 'Build and Push Release Image' - condition: contains(variables['Build.SourceBranch'], 'refs/tags/v') - - - pwsh: | - $configPath = "$(Agent.TempDirectory)/hidi-docker.nuget.config" - if (Test-Path $configPath) { - Remove-Item $configPath -Force - } - displayName: 'Remove Docker NuGet config' - condition: always() - # once the nuget has been released, fill this form to get the public documentation updated. # https://dev.azure.com/msft-skilling/Content/_workitems/create/User%20Story?templateId=39fb91e3-64a2-4c8a-83db-b2bdf3603dd3&ownerId=c4a28f90-17ae-4384-b514-7273392b082b # https://learn.microsoft.com/en-us/dotnet/api/microsoft.openapi diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index b2311adf8..576283c02 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -44,8 +44,7 @@ jobs: run: | $projectsArray = @( '.\src\Microsoft.OpenApi\Microsoft.OpenApi.csproj', - '.\src\Microsoft.OpenApi.YamlReader\Microsoft.OpenApi.YamlReader.csproj', - '.\src\Microsoft.OpenApi.Hidi\Microsoft.OpenApi.Hidi.csproj' + '.\src\Microsoft.OpenApi.YamlReader\Microsoft.OpenApi.YamlReader.csproj' ) $projectsArray | ForEach-Object { diff --git a/.vscode/launch.json b/.vscode/launch.json index ad2bdf11d..fb87186c4 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,24 +1,6 @@ { "version": "0.2.0", "configurations": [ - { - // Use IntelliSense to find out which attributes exist for C# debugging - // Use hover for the description of the existing attributes - // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/main/debugger-launchjson.md - "name": "Launch Hidi", - "type": "coreclr", - "request": "launch", - "preLaunchTask": "build", - // If you have changed target frameworks, make sure to update the program path. - "program": "${workspaceFolder}/src/Microsoft.OpenApi.Hidi/bin/Debug/net8.0/Microsoft.OpenApi.Hidi.dll", - "args": ["plugin", - "-m","${workspaceFolder}/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/exampleapimanifest.json", - "--of","./output"], - "cwd": "${workspaceFolder}/src/Microsoft.OpenApi.Hidi", - // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console - "console": "internalConsole", - "stopAtEntry": false - }, { // Use IntelliSense to find out which attributes exist for C# debugging // Use hover for the description of the existing attributes diff --git a/.vscode/settings.json b/.vscode/settings.json index 619467ff3..4bfa8971f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -6,7 +6,6 @@ }, "cSpell.words": [ "csdl", - "Hidi", "Xunit" ] } \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index c61ccd31c..4372c2f45 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -29,20 +29,6 @@ "--collect:\"XPlat Code Coverage\"" ], "problemMatcher": "$msCompile" - }, - { - "label": "watch", - "command": "dotnet", - "type": "process", - "group": "build", - "args": [ - "watch", - "run", - "${workspaceFolder}/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj", - "/property:GenerateFullPaths=true", - "/consoleloggerparameters:NoSummary" - ], - "problemMatcher": "$msCompile" } ] } \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7719a3839..98e928d47 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -8,7 +8,9 @@ OpenAPI.net is a mono-repo containing source code for the following packages: |----------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [Microsoft.OpenAPI](./src/Microsoft.OpenAPI/README.md) | [![NuGet Version](https://img.shields.io/nuget/vpre/Microsoft.OpenAPI?label=Latest&logo=nuget)](https://www.nuget.org/packages/Microsoft.OpenAPI/) | | [Microsoft.OpenAPI.YamlReader](./src/Microsoft.OpenApi.YamlReader/README.md) | [![NuGet Version](https://img.shields.io/nuget/vpre/Microsoft.OpenAPI.YamlReader?label=Latest&logo=nuget)](https://www.nuget.org/packages/Microsoft.OpenAPI.YamlReader/) | -| [Microsoft.OpenAPI.Hidi](./src/Microsoft.OpenAPI.Hidi/README.md) | [![NuGet Version](https://img.shields.io/nuget/vpre/Microsoft.OpenAPI.Hidi?label=Latest&logo=nuget)](https://www.nuget.org/packages/Microsoft.OpenAPI.Hidi/) | + +The OpenAPI.NET v3-compatible [Microsoft.OpenApi.Hidi command line tool](https://github.com/microsoft/OpenAPI.NET.OData/blob/main/src/Microsoft.OpenApi.Hidi/readme.md) is maintained separately. +Contribute to Hidi in [OpenAPI.NET.OData's main branch](https://github.com/microsoft/OpenAPI.NET.OData/tree/main). OpenAPI.net is open to contributions. There are a couple of different recommended paths to get contributions into the released version of this library. diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 4e932b975..000000000 --- a/Dockerfile +++ /dev/null @@ -1,25 +0,0 @@ -FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build-env -WORKDIR /app - -COPY ./src ./hidi/src -COPY ./Directory.Build.props ./hidi/Directory.Build.props -COPY ./README.md ./hidi/README.md -WORKDIR /app/hidi -# CI supplies the private feed config as a secret; local builds use default NuGet sources. -RUN --mount=type=secret,id=nuget_config,target=/app/hidi/NuGet.Config \ - dotnet publish ./src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj -c Release - -FROM mcr.microsoft.com/dotnet/runtime:8.0-jammy-chiseled AS runtime -WORKDIR /app - -COPY --from=build-env /app/hidi/src/Microsoft.OpenApi.Hidi/bin/Release/net8.0 ./ - -VOLUME /app/output -VOLUME /app/openapi.yml -VOLUME /app/api.csdl -VOLUME /app/collection.json -ENV HIDI_CONTAINER=true DOTNET_TieredPGO=1 DOTNET_TC_QuickJitForLoops=1 -ENTRYPOINT ["dotnet", "Microsoft.OpenApi.Hidi.dll"] -LABEL description="# Welcome to Hidi \ -To start transforming OpenAPI documents checkout [the getting started documentation](https://github.com/microsoft/OpenAPI.NET/tree/main/src/Microsoft.OpenApi.Hidi) \ -[Source dockerfile](https://github.com/microsoft/OpenAPI.NET/blob/main/Dockerfile)" diff --git a/Microsoft.OpenApi.slnx b/Microsoft.OpenApi.slnx index 8356bb428..007071a9e 100644 --- a/Microsoft.OpenApi.slnx +++ b/Microsoft.OpenApi.slnx @@ -8,12 +8,10 @@ - - diff --git a/README.md b/README.md index 8622d64d8..a4cf4171e 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,6 @@ |--|--| |Models and Writers|[![nuget](https://img.shields.io/nuget/v/Microsoft.OpenApi.svg)](https://www.nuget.org/packages/Microsoft.OpenApi/) | |YamlReader | [![nuget](https://img.shields.io/nuget/v/Microsoft.OpenApi.YamlReader.svg)](https://www.nuget.org/packages/Microsoft.OpenApi.YamlReader/) | -|Hidi|[![nuget](https://img.shields.io/nuget/v/Microsoft.OpenApi.Hidi.svg)](https://www.nuget.org/packages/Microsoft.OpenApi.Hidi/) The **OpenAPI.NET** SDK contains a useful object model for OpenAPI documents in .NET along with common serializers to extract raw OpenAPI JSON and YAML documents from the model. @@ -86,10 +85,9 @@ var outputString = await openApiDocument.SerializeAsJsonAsync(OpenApiSpecVersion ``` # Validating/Testing OpenAPI descriptions -In order to test the validity of an OpenApi document, we avail the following tools: -- [Microsoft.OpenApi.Hidi](https://www.nuget.org/packages/Microsoft.OpenApi.Hidi) - - A commandline tool for validating and transforming OpenAPI descriptions. [Installation guidelines and documentation](https://github.com/microsoft/OpenAPI.NET/blob/main/src/Microsoft.OpenApi.Hidi/readme.md) +[Microsoft.OpenApi.Hidi](https://www.nuget.org/packages/Microsoft.OpenApi.Hidi) is a command line tool for validating and transforming OpenAPI descriptions. +The OpenAPI.NET v3-compatible tool is maintained in [OpenAPI.NET.OData's main branch](https://github.com/microsoft/OpenAPI.NET.OData/tree/main/src/Microsoft.OpenApi.Hidi). +See its [installation guidelines and documentation](https://github.com/microsoft/OpenAPI.NET.OData/blob/main/src/Microsoft.OpenApi.Hidi/readme.md). # Contributing diff --git a/build.cmd b/build.cmd index 07daf7b6c..4fa04e44a 100644 --- a/build.cmd +++ b/build.cmd @@ -13,11 +13,4 @@ dotnet msbuild %PROJ% /t:restore /p:Configuration=Release dotnet msbuild %PROJ% /t:build /p:Configuration=Release dotnet msbuild %PROJ% /t:pack /p:Configuration=Release;PackageOutputPath=%~dp0artifacts -Echo Building Microsoft.OpenApi.Hidi - -SET PROJ=%~dp0src\Microsoft.OpenApi.Hidi\Microsoft.OpenApi.Hidi.csproj -dotnet msbuild %PROJ% /t:restore /p:Configuration=Release -dotnet msbuild %PROJ% /t:build /p:Configuration=Release -dotnet msbuild %PROJ% /t:pack /p:Configuration=Release;PackageOutputPath=%~dp0artifacts - :end diff --git a/build.sh b/build.sh index 0de30b6df..1e6ae6313 100755 --- a/build.sh +++ b/build.sh @@ -12,11 +12,4 @@ echo "Building Microsoft.OpenApi.YamlReader" PROJ="$(dirname "$0")/src/Microsoft.OpenApi.YamlReader/Microsoft.OpenApi.YamlReader.csproj" dotnet msbuild "$PROJ" /t:restore /p:Configuration=Release dotnet msbuild "$PROJ" /t:build /p:Configuration=Release -dotnet msbuild "$PROJ" /t:pack "/p:Configuration=Release;PackageOutputPath=$(dirname "$0")/artifacts" - -echo "Building Microsoft.OpenApi.Hidi" - -PROJ="$(dirname "$0")/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj" -dotnet msbuild "$PROJ" /t:restore /p:Configuration=Release -dotnet msbuild "$PROJ" /t:build /p:Configuration=Release dotnet msbuild "$PROJ" /t:pack "/p:Configuration=Release;PackageOutputPath=$(dirname "$0")/artifacts" \ No newline at end of file diff --git a/install-tool.ps1 b/install-tool.ps1 deleted file mode 100644 index 0b4615c67..000000000 --- a/install-tool.ps1 +++ /dev/null @@ -1,7 +0,0 @@ -$latest = Get-ChildItem .\artifacts\Microsoft.OpenApi.Hidi* | select-object -Last 1 -$version = $latest.Name.Split(".")[3..5] | join-string -Separator "." - -if (Test-Path -Path ./artifacts/hidi.exe) { - dotnet tool uninstall --tool-path artifacts Microsoft.OpenApi.Hidi -} -dotnet tool install --tool-path artifacts --add-source .\artifacts\ --version $version Microsoft.OpenApi.Hidi \ No newline at end of file diff --git a/src/Microsoft.OpenApi.Hidi/CsdlFilter.xslt b/src/Microsoft.OpenApi.Hidi/CsdlFilter.xslt deleted file mode 100644 index ee3bf0d40..000000000 --- a/src/Microsoft.OpenApi.Hidi/CsdlFilter.xslt +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/src/Microsoft.OpenApi.Hidi/Extensions/CommandExtensions.cs b/src/Microsoft.OpenApi.Hidi/Extensions/CommandExtensions.cs deleted file mode 100644 index 1a2dc477d..000000000 --- a/src/Microsoft.OpenApi.Hidi/Extensions/CommandExtensions.cs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. - -using System.Collections.Generic; -using System.CommandLine; - -namespace Microsoft.OpenApi.Hidi.Extensions -{ - internal static class CommandExtensions - { - public static void AddOptions(this Command command, IReadOnlyList public class OpenApiWriterSettings { + private const int DefaultMaxInlineReferenceCount = 10_000; + internal LoopDetector LoopDetector { get; } = new(); + /// /// Indicates if local references should be rendered as an inline object /// @@ -16,6 +19,12 @@ public class OpenApiWriterSettings /// public bool InlineExternalReferences { get; set; } + /// + /// Gets or sets the maximum number of references that can be expanded inline by a writer. + /// + /// The default is 10,000. + public int MaxInlineReferenceCount { get; set; } = DefaultMaxInlineReferenceCount; + internal bool ShouldInlineReference(BaseOpenApiReference reference) { return (reference.IsLocal && InlineLocalReferences) diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterInlineReferenceTests.cs b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterInlineReferenceTests.cs new file mode 100644 index 000000000..0c49a66d1 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterInlineReferenceTests.cs @@ -0,0 +1,337 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Text; +using Xunit; + +namespace Microsoft.OpenApi.Tests.Writers +{ + public class OpenApiWriterInlineReferenceTests + { + private const int InlineReferenceLimit = 128; + private const int OutputCharacterLimit = 100_000; + + [Theory] + [InlineData(OpenApiSpecVersion.OpenApi2_0, false)] + [InlineData(OpenApiSpecVersion.OpenApi2_0, true)] + [InlineData(OpenApiSpecVersion.OpenApi3_0, false)] + [InlineData(OpenApiSpecVersion.OpenApi3_0, true)] + [InlineData(OpenApiSpecVersion.OpenApi3_1, false)] + [InlineData(OpenApiSpecVersion.OpenApi3_1, true)] + [InlineData(OpenApiSpecVersion.OpenApi3_2, false)] + [InlineData(OpenApiSpecVersion.OpenApi3_2, true)] + public void SerializeWithRepeatedInlineReferencesStopsBeforeWriterLimit( + OpenApiSpecVersion specVersion, + bool useYaml) + { + var readResult = OpenApiDocument.Parse(CreateDocumentWithRepeatedReferences(18), "json"); + Assert.Empty(readResult.Diagnostic.Errors); + Assert.NotNull(readResult.Document); + + using var textWriter = new CharacterLimitedTextWriter(OutputCharacterLimit); + IOpenApiWriter writer = useYaml + ? new OpenApiYamlWriter(textWriter, CreateWriterSettings(InlineReferenceLimit)) + : new OpenApiJsonWriter(textWriter, CreateWriterSettings(InlineReferenceLimit)); + + var exception = Assert.Throws( + () => Serialize(readResult.Document, writer, specVersion)); + Assert.Contains(InlineReferenceLimit.ToString(CultureInfo.InvariantCulture), exception.Message); + } + + [Theory] + [InlineData(OpenApiSpecVersion.OpenApi2_0)] + [InlineData(OpenApiSpecVersion.OpenApi3_0)] + [InlineData(OpenApiSpecVersion.OpenApi3_1)] + [InlineData(OpenApiSpecVersion.OpenApi3_2)] + public void SerializeWithInlineReferencesBelowLimitWorks(OpenApiSpecVersion specVersion) + { + var readResult = OpenApiDocument.Parse(CreateDocumentWithRepeatedReferences(4), "json"); + Assert.Empty(readResult.Diagnostic.Errors); + Assert.NotNull(readResult.Document); + + using var textWriter = new StringWriter(CultureInfo.InvariantCulture); + var writer = new OpenApiJsonWriter(textWriter, CreateWriterSettings(32)); + + Serialize(readResult.Document, writer, specVersion); + + Assert.NotEmpty(textWriter.ToString()); + } + + [Fact] + public void ReusingSettingsWithNewWriterStartsANewInlineReferenceCount() + { + var largeReadResult = OpenApiDocument.Parse(CreateDocumentWithRepeatedReferences(6), "json"); + Assert.Empty(largeReadResult.Diagnostic.Errors); + Assert.NotNull(largeReadResult.Document); + var smallReadResult = OpenApiDocument.Parse(CreateDocumentWithRepeatedReferences(4), "json"); + Assert.Empty(smallReadResult.Diagnostic.Errors); + Assert.NotNull(smallReadResult.Document); + var settings = CreateWriterSettings(32); + + using var firstOutput = new StringWriter(CultureInfo.InvariantCulture); + Assert.Throws( + () => Serialize( + largeReadResult.Document, + new OpenApiJsonWriter(firstOutput, settings), + OpenApiSpecVersion.OpenApi3_0)); + + using var secondOutput = new StringWriter(CultureInfo.InvariantCulture); + Serialize( + smallReadResult.Document, + new OpenApiJsonWriter(secondOutput, settings), + OpenApiSpecVersion.OpenApi3_0); + + Assert.DoesNotContain("$ref", secondOutput.ToString()); + } + + [Theory] + [InlineData(OpenApiSpecVersion.OpenApi3_0)] + [InlineData(OpenApiSpecVersion.OpenApi3_1)] + public void SerializeMediaTypeReferenceUsesInlineReferenceCount(OpenApiSpecVersion specVersion) + { + var document = new OpenApiDocument + { + Components = new OpenApiComponents + { + MediaTypes = new Dictionary + { + ["shared"] = new OpenApiMediaType + { + Schema = new OpenApiSchema { Type = JsonSchemaType.String } + } + } + } + }; + document.Workspace.RegisterComponents(document); + var reference = new OpenApiMediaTypeReference("shared", document); + using var output = new StringWriter(CultureInfo.InvariantCulture); + var writer = new OpenApiJsonWriter(output, CreateWriterSettings(0)); + + Assert.Throws(() => Serialize(reference, writer, specVersion)); + } + + [Fact] + public void ConvertRequestBodyReferenceToV2ParameterUsesInlineReferenceCount() + { + var document = CreateDocumentWithRequestBodyComponent(); + var reference = new OpenApiRequestBodyReference("shared", document); + using var output = new StringWriter(CultureInfo.InvariantCulture); + var writer = new OpenApiJsonWriter(output, CreateWriterSettings(0)); + + Assert.Throws(() => reference.ConvertToBodyParameter(writer)); + Assert.Throws(() => reference.ConvertToFormDataParameters(writer)); + } + + [Fact] + public void SerializeV2HeaderSchemaReferenceUsesInlineReferenceCount() + { + var document = CreateDocumentWithSchemaComponent(); + var header = new OpenApiHeader + { + Schema = new OpenApiSchemaReference("shared", document) + }; + using var output = new StringWriter(CultureInfo.InvariantCulture); + var writer = new OpenApiJsonWriter(output, CreateWriterSettings(0)); + + Assert.Throws(() => header.SerializeAsV2(writer)); + } + + [Fact] + public void SerializeV2ParameterSchemaReferenceUsesInlineReferenceCount() + { + var document = CreateDocumentWithSchemaComponent(); + var parameter = new OpenApiParameter + { + Name = "value", + In = ParameterLocation.Query, + Schema = new OpenApiSchemaReference("shared", document) + }; + using var output = new StringWriter(CultureInfo.InvariantCulture); + var writer = new OpenApiJsonWriter(output, CreateWriterSettings(0)); + + Assert.Throws(() => parameter.SerializeAsV2(writer)); + } + + private static OpenApiDocument CreateDocumentWithRequestBodyComponent() + { + var document = new OpenApiDocument + { + Components = new OpenApiComponents + { + RequestBodies = new Dictionary + { + ["shared"] = new OpenApiRequestBody + { + Content = new Dictionary + { + ["application/x-www-form-urlencoded"] = new OpenApiMediaType + { + Schema = new OpenApiSchema + { + Type = JsonSchemaType.Object, + Properties = new Dictionary + { + ["value"] = new OpenApiSchema { Type = JsonSchemaType.String } + } + } + } + } + } + } + } + }; + document.Workspace.RegisterComponents(document); + return document; + } + + private static OpenApiDocument CreateDocumentWithSchemaComponent() + { + var document = new OpenApiDocument + { + Components = new OpenApiComponents + { + Schemas = new Dictionary + { + ["shared"] = new OpenApiSchema { Type = JsonSchemaType.String } + } + } + }; + document.Workspace.RegisterComponents(document); + return document; + } + + private static string CreateDocumentWithRepeatedReferences(int levels) + { + var schemas = new StringBuilder(); + for (var i = 0; i < levels; i++) + { + if (i > 0) + { + schemas.Append(','); + } + + schemas + .Append("\"s") + .Append(i.ToString(CultureInfo.InvariantCulture)) + .Append("\":{\"allOf\":[{\"$ref\":\"#/components/schemas/s") + .Append((i + 1).ToString(CultureInfo.InvariantCulture)) + .Append("\"},{\"$ref\":\"#/components/schemas/s") + .Append((i + 1).ToString(CultureInfo.InvariantCulture)) + .Append("\"}]}"); + } + + schemas + .Append(",\"s") + .Append(levels.ToString(CultureInfo.InvariantCulture)) + .Append("\":{\"type\":\"string\"}"); + + return $$""" + { + "openapi": "3.0.0", + "info": { + "title": "Repeated references", + "version": "1.0.0" + }, + "paths": { + "/test": { + "get": { + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/s0" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + {{schemas}} + } + } + } + """; + } + + private static void Serialize( + IOpenApiSerializable serializable, + IOpenApiWriter writer, + OpenApiSpecVersion specVersion) + { + switch (specVersion) + { + case OpenApiSpecVersion.OpenApi2_0: + serializable.SerializeAsV2(writer); + break; + case OpenApiSpecVersion.OpenApi3_0: + serializable.SerializeAsV3(writer); + break; + case OpenApiSpecVersion.OpenApi3_1: + serializable.SerializeAsV31(writer); + break; + case OpenApiSpecVersion.OpenApi3_2: + serializable.SerializeAsV32(writer); + break; + default: + throw new ArgumentOutOfRangeException(nameof(specVersion), specVersion, null); + } + } + + private static OpenApiWriterSettings CreateWriterSettings(int maxInlineReferenceCount) + { + return new OpenApiWriterSettings + { + InlineLocalReferences = true, + MaxInlineReferenceCount = maxInlineReferenceCount + }; + } + + private sealed class CharacterLimitedTextWriter(int characterLimit) : TextWriter + { + private int _characterCount; + + public override Encoding Encoding => Encoding.UTF8; + + public override void Write(char value) + { + CountCharacters(1); + } + + public override void Write(string value) + { + CountCharacters(value?.Length ?? 0); + } + + public override void Write(char[] buffer, int index, int count) + { + CountCharacters(count); + } + + public override void Write(ReadOnlySpan buffer) + { + CountCharacters(buffer.Length); + } + + private void CountCharacters(int count) + { + _characterCount += count; + if (_characterCount > characterLimit) + { + throw new CharacterLimitExceededException(); + } + } + } + + private sealed class CharacterLimitExceededException : Exception; + } +} From 9bc20057e9e626c0cb07f8bc39eaa95a0e98fdde Mon Sep 17 00:00:00 2001 From: "release-please-token-provider[bot]" <225477224+release-please-token-provider[bot]@users.noreply.github.com> Date: Mon, 19 Oct 2026 17:03:20 +0000 Subject: [PATCH 955/984] automatic promotion of shipped APIs for main (#3127) chore: promote shipped APIs Co-authored-by: release-please-token-provider[bot] <225477224+release-please-token-provider[bot]@users.noreply.github.com> --- src/Microsoft.OpenApi/PublicAPI.Shipped.txt | 3 +++ src/Microsoft.OpenApi/PublicAPI.Unshipped.txt | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.OpenApi/PublicAPI.Shipped.txt b/src/Microsoft.OpenApi/PublicAPI.Shipped.txt index ba435ff4e..b36bb7d11 100644 --- a/src/Microsoft.OpenApi/PublicAPI.Shipped.txt +++ b/src/Microsoft.OpenApi/PublicAPI.Shipped.txt @@ -2287,3 +2287,6 @@ Microsoft.OpenApi.OpenApiWorkspace.GetDynamicAnchorCandidates(Microsoft.OpenApi. static Microsoft.OpenApi.OpenApiWorkspace.ResolveDynamicAnchorInContext(Microsoft.OpenApi.IOpenApiSchema? contextSchema, string! anchorName) -> Microsoft.OpenApi.IOpenApiSchema? const Microsoft.OpenApi.OpenApiConstants.JsonSchemaExamplesExtension = "x-jsonschema-examples" -> string! const Microsoft.OpenApi.OpenApiConstants.OaiLicenseIdentifier = "x-oai-license-identifier" -> string! +Microsoft.OpenApi.OpenApiDocument.GetOperationById(string! operationId) -> Microsoft.OpenApi.OpenApiOperation? +Microsoft.OpenApi.OpenApiWriterSettings.MaxInlineReferenceCount.get -> int +Microsoft.OpenApi.OpenApiWriterSettings.MaxInlineReferenceCount.set -> void diff --git a/src/Microsoft.OpenApi/PublicAPI.Unshipped.txt b/src/Microsoft.OpenApi/PublicAPI.Unshipped.txt index cb0df9c08..7dc5c5811 100644 --- a/src/Microsoft.OpenApi/PublicAPI.Unshipped.txt +++ b/src/Microsoft.OpenApi/PublicAPI.Unshipped.txt @@ -1,4 +1 @@ #nullable enable -Microsoft.OpenApi.OpenApiDocument.GetOperationById(string! operationId) -> Microsoft.OpenApi.OpenApiOperation? -Microsoft.OpenApi.OpenApiWriterSettings.MaxInlineReferenceCount.get -> int -Microsoft.OpenApi.OpenApiWriterSettings.MaxInlineReferenceCount.set -> void From 2fea8ae4ee7ce6b9c313fa0822f5c617da18c351 Mon Sep 17 00:00:00 2001 From: "release-please-token-provider[bot]" <225477224+release-please-token-provider[bot]@users.noreply.github.com> Date: Mon, 19 Oct 2026 13:04:49 -0400 Subject: [PATCH 956/984] chore(main): release 3.11.0 (#3071) Co-authored-by: release-please-token-provider[bot] <225477224+release-please-token-provider[bot]@users.noreply.github.com> --- .release-please-manifest.json | 2 +- CHANGELOG.md | 15 +++++++++++++++ Directory.Build.props | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index f7929cb4c..940f2ca3e 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "3.10.2" + ".": "3.11.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 0077ae140..a3114853b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,20 @@ # Changelog +## [3.11.0](https://github.com/microsoft/OpenAPI.NET/compare/v3.10.2...v3.11.0) (2026-10-19) + + +### Features + +* **document:** add GetOperationById to search operations across path… ([#3025](https://github.com/microsoft/OpenAPI.NET/issues/3025)) ([1dae1ff](https://github.com/microsoft/OpenAPI.NET/commit/1dae1fff4fcd8170f38672593a30b023a66c052c)) + + +### Bug Fixes + +* components-key validation timeouts under load ([#3108](https://github.com/microsoft/OpenAPI.NET/issues/3108)) ([01d4729](https://github.com/microsoft/OpenAPI.NET/commit/01d472995b3c466feb5bbf61e303bcd7752da16a)) +* **openapi:** omit null response descriptions ([afd4967](https://github.com/microsoft/OpenAPI.NET/commit/afd4967a9e6db390175e2df9e6f34ff77168d19d)) +* **serialization:** potential infinite loop when inlining references ([c6ef130](https://github.com/microsoft/OpenAPI.NET/commit/c6ef130bd7f3bf55c59735b25392a58a599701fc)) +* **serialization:** references inlining ([#3124](https://github.com/microsoft/OpenAPI.NET/issues/3124)) ([c6ef130](https://github.com/microsoft/OpenAPI.NET/commit/c6ef130bd7f3bf55c59735b25392a58a599701fc)) + ## [3.10.2](https://github.com/microsoft/OpenAPI.NET/compare/v3.10.1...v3.10.2) (2026-08-20) diff --git a/Directory.Build.props b/Directory.Build.props index 1971fa2c6..b460cb537 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -14,7 +14,7 @@ https://github.com/Microsoft/OpenAPI.NET © Microsoft Corporation. All rights reserved. OpenAPI .NET - 3.10.2 + 3.11.0 From 2c65eb23b327d2f0864616e6ae756fbacff296c4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Oct 2026 17:49:56 -0400 Subject: [PATCH 957/984] chore(deps): bump actions/create-github-app-token from 3.2.0 to 3.3.0 (#3129) Bumps [actions/create-github-app-token](https://github.com/actions/create-github-app-token) from 3.2.0 to 3.3.0. - [Release notes](https://github.com/actions/create-github-app-token/releases) - [Changelog](https://github.com/actions/create-github-app-token/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/create-github-app-token/compare/bcd2ba49218906704ab6c1aa796996da409d3eb1...64ab729a6294000f5aa4a4bc0b73d1f32bc45510) --- updated-dependencies: - dependency-name: actions/create-github-app-token dependency-version: 3.3.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/promote-shipped-apis.yml | 2 +- .github/workflows/release-please-gha.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/promote-shipped-apis.yml b/.github/workflows/promote-shipped-apis.yml index 825b8944f..a93ac994b 100644 --- a/.github/workflows/promote-shipped-apis.yml +++ b/.github/workflows/promote-shipped-apis.yml @@ -20,7 +20,7 @@ jobs: steps: - name: Generate GitHub App token id: app-token - uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0 + uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0 with: client-id: ${{ vars.RELEASE_PLEASE_TOKEN_PROVIDER_APP_ID }} private-key: ${{ secrets.RELEASE_PLEASE_TOKEN_PROVIDER_PEM }} diff --git a/.github/workflows/release-please-gha.yml b/.github/workflows/release-please-gha.yml index 74a6233fb..069cbcecb 100644 --- a/.github/workflows/release-please-gha.yml +++ b/.github/workflows/release-please-gha.yml @@ -62,7 +62,7 @@ jobs: - name: Generate GitHub App token id: app-token - uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0 + uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0 with: client-id: ${{ vars.RELEASE_PLEASE_TOKEN_PROVIDER_APP_ID }} private-key: ${{ secrets.RELEASE_PLEASE_TOKEN_PROVIDER_PEM }} From 30d1296ca4d0503c788214ea6a3793b6f0cb1951 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Oct 2026 17:50:36 -0400 Subject: [PATCH 958/984] Bump Microsoft.VisualStudio.Threading.Analyzers from 18.7.23 to 18.12.1 (#3130) --- updated-dependencies: - dependency-name: Microsoft.VisualStudio.Threading.Analyzers dependency-version: 18.12.1 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .../Microsoft.OpenApi.YamlReader.csproj | 2 +- src/Microsoft.OpenApi/Microsoft.OpenApi.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi.YamlReader/Microsoft.OpenApi.YamlReader.csproj b/src/Microsoft.OpenApi.YamlReader/Microsoft.OpenApi.YamlReader.csproj index 5a04ce302..3319526ee 100644 --- a/src/Microsoft.OpenApi.YamlReader/Microsoft.OpenApi.YamlReader.csproj +++ b/src/Microsoft.OpenApi.YamlReader/Microsoft.OpenApi.YamlReader.csproj @@ -30,7 +30,7 @@ - + diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj index 8e1ebb555..5f65bd08f 100644 --- a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj +++ b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj @@ -51,7 +51,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all From 00c0a2639a3e41e495e8a3c8bec811c80d81dc08 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Oct 2026 17:53:51 -0400 Subject: [PATCH 959/984] Bump Verify.XunitV3 from 33.3.2 to 33.3.3 (#3131) --- updated-dependencies: - dependency-name: Verify.XunitV3 dependency-version: 33.3.3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- 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 5ba2701b5..66f852384 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -14,7 +14,7 @@ - + From d8684318ce83c4a573f83bcd9560c98caac1bfe7 Mon Sep 17 00:00:00 2001 From: Hardik K Date: Tue, 20 Oct 2026 23:01:21 +0530 Subject: [PATCH 960/984] fix: Support custom tag ordering and null assignment in OpenApiOperation.Tags (#3128) * fix: Support custom tag ordering and null assignment in OpenApiOperation.Tags Fixes #3115 * fix: use explicit comparer identity check --- .../Models/OpenApiOperation.cs | 18 +++- .../Models/OpenApiOperationTests.cs | 90 ++++++++++++++++++- 2 files changed, 103 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.OpenApi/Models/OpenApiOperation.cs b/src/Microsoft.OpenApi/Models/OpenApiOperation.cs index ee1afcc0a..20ce8bf53 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiOperation.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiOperation.cs @@ -1,8 +1,11 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System; using System.Collections.Generic; +#if NET +using System.Collections.Immutable; +#endif using System.Linq; namespace Microsoft.OpenApi @@ -27,11 +30,18 @@ public ISet? Tags { if (value is null) { + _tags = null; return; } - _tags = value is HashSet tags && tags.Comparer is OpenApiTagComparer ? - tags : - new HashSet(value, OpenApiTagComparer.Instance); + _tags = value switch + { + HashSet tags when !ReferenceEquals(tags.Comparer, EqualityComparer.Default) => value, + SortedSet => value, +#if NET + ImmutableSortedSet => value, +#endif + _ => new HashSet(value, OpenApiTagComparer.Instance), + }; } } diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs index d281f4437..46e25c183 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs @@ -1,7 +1,11 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. +using System; using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Linq; using System.Text.Json.Nodes; using System.Threading.Tasks; using Xunit; @@ -851,5 +855,89 @@ public void OpenApiOperationCopyConstructorWithAnnotationsSucceeds() Assert.NotEqual(baseOperation.Metadata["key1"], actualOperation.Metadata["key1"]); } + + [Fact] + public void TagsCanBeReInitializedToNull() + { + var operation = new OpenApiOperation(); + Assert.Null(operation.Tags); + operation.Tags = new HashSet(); + Assert.NotNull(operation.Tags); + operation.Tags = null; + Assert.Null(operation.Tags); + } + + [Fact] + public void TagsSupportsCustomComparer() + { + var operation = new OpenApiOperation + { + Tags = new HashSet(new CaseInsensitiveOpenApiTagReferenceEqualityComparer()), + }; + + Assert.True(operation.Tags.Add(new OpenApiTagReference("Tag1"))); + Assert.False(operation.Tags.Add(new OpenApiTagReference("tag1"))); + Assert.True(operation.Tags.Add(new OpenApiTagReference("tag2"))); + Assert.False(operation.Tags.Add(new OpenApiTagReference("TAG1"))); + Assert.Equal(2, operation.Tags.Count); + } + + private sealed class CaseInsensitiveOpenApiTagReferenceEqualityComparer : IEqualityComparer + { + public bool Equals(OpenApiTagReference x, OpenApiTagReference y) + { + return string.Equals(x?.Name, y?.Name, StringComparison.OrdinalIgnoreCase); + } + + public int GetHashCode([DisallowNull] OpenApiTagReference obj) + { + return obj.Name?.GetHashCode(StringComparison.OrdinalIgnoreCase) ?? 0; + } + } + + [Fact] + public void TagsSupportsSortedSets() + { + var operation = new OpenApiOperation + { + Tags = new SortedSet(new DescendingOpenApiTagReferenceComparer()) + { + new("tagB"), + new("tagA"), + new("tagC"), + } + }; + + var names = operation.Tags.Select(t => t.Name); + Assert.Equal(["tagC", "tagB", "tagA"], names); + Assert.IsType>(operation.Tags); + } + + private sealed class DescendingOpenApiTagReferenceComparer : IComparer + { + public int Compare(OpenApiTagReference x, OpenApiTagReference y) + { + return string.Compare(y?.Name, x?.Name, StringComparison.Ordinal); + } + } + + [Fact] + public void TagsSupportsImmutableSortedSets() + { + var operation = new OpenApiOperation + { + Tags = ImmutableSortedSet.Create( + new DescendingOpenApiTagReferenceComparer(), + [ + new OpenApiTagReference("tagB"), + new OpenApiTagReference("tagA"), + new OpenApiTagReference("tagC"), + ]), + }; + + var names = operation.Tags.Select(t => t.Name); + Assert.Equal(["tagC", "tagB", "tagA"], names); + Assert.IsType>(operation.Tags); + } } } From 51aa19aef6f4be8854fc014cfd82331fab6051d0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 21 Oct 2026 05:16:36 -0400 Subject: [PATCH 961/984] Bump System.Text.Json from 10.0.12 to 10.0.13 (#3140) --- updated-dependencies: - dependency-name: System.Text.Json dependency-version: 10.0.13 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- performance/resultsComparer/resultsComparer.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/performance/resultsComparer/resultsComparer.csproj b/performance/resultsComparer/resultsComparer.csproj index 9767a28ba..30e6a07d2 100644 --- a/performance/resultsComparer/resultsComparer.csproj +++ b/performance/resultsComparer/resultsComparer.csproj @@ -13,7 +13,7 @@ - + From 016d588b93914d49e69bfe39c5137bee1d16b166 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 21 Oct 2026 05:16:49 -0400 Subject: [PATCH 962/984] Bump Microsoft.SourceLink.GitHub from 10.0.401 to 10.0.402 (#3138) --- updated-dependencies: - dependency-name: Microsoft.SourceLink.GitHub dependency-version: 10.0.402 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index b460cb537..063a25831 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -21,6 +21,6 @@ true - + \ No newline at end of file From ebff4a166c8a4bb48e7bad009616d087b736e55f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 21 Oct 2026 05:17:30 -0400 Subject: [PATCH 963/984] Bump the microsoftextensions group with 5 updates (#3136) Bumps Microsoft.Extensions.DependencyInjection from 10.0.12 to 10.0.13 Bumps Microsoft.Extensions.Logging from 10.0.12 to 10.0.13 Bumps Microsoft.Extensions.Logging.Console from 10.0.12 to 10.0.13 Bumps Microsoft.Extensions.Logging.Debug from 10.0.12 to 10.0.13 Bumps System.Text.Json from 10.0.12 to 10.0.13 --- updated-dependencies: - dependency-name: Microsoft.Extensions.DependencyInjection dependency-version: 10.0.13 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: microsoftextensions - dependency-name: Microsoft.Extensions.Logging dependency-version: 10.0.13 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: microsoftextensions - dependency-name: Microsoft.Extensions.Logging.Console dependency-version: 10.0.13 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: microsoftextensions - dependency-name: System.Text.Json dependency-version: 10.0.13 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: microsoftextensions - dependency-name: Microsoft.Extensions.Logging.Debug dependency-version: 10.0.13 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: microsoftextensions ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- performance/resultsComparer/resultsComparer.csproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/performance/resultsComparer/resultsComparer.csproj b/performance/resultsComparer/resultsComparer.csproj index 30e6a07d2..453944872 100644 --- a/performance/resultsComparer/resultsComparer.csproj +++ b/performance/resultsComparer/resultsComparer.csproj @@ -8,10 +8,10 @@ - - - - + + + + From 994b3770fa50d46ea60ef53b932f4f4a929e6e64 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 21 Oct 2026 05:18:53 -0400 Subject: [PATCH 964/984] Bump the testing group with 1 update (#3137) Bumps Microsoft.NET.Test.Sdk from 18.10.1 to 18.11.0 --- updated-dependencies: - dependency-name: Microsoft.NET.Test.Sdk dependency-version: 18.11.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: testing - dependency-name: Microsoft.NET.Test.Sdk dependency-version: 18.11.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: testing ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .../Microsoft.OpenApi.Readers.Tests.csproj | 2 +- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj index ec8146228..0c6d93ee0 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj +++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj @@ -17,7 +17,7 @@ - + diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 66f852384..b77085ac2 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -10,7 +10,7 @@ - + From 798b16120f81bb6d2ebaed3c1f541d9afc1f59d4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 21 Oct 2026 05:31:48 -0400 Subject: [PATCH 965/984] chore(deps): bump dotnet-sdk from 10.0.401 to 10.0.402 (#3135) Bumps [dotnet-sdk](https://github.com/dotnet/sdk) from 10.0.401 to 10.0.402. - [Release notes](https://github.com/dotnet/sdk/releases) - [Commits](https://github.com/dotnet/sdk/compare/v10.0.401...v10.0.402) --- updated-dependencies: - dependency-name: dotnet-sdk dependency-version: 10.0.402 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index 7494875e1..c92eedfeb 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "10.0.401" + "version": "10.0.402" }, "test": { "runner": "Microsoft.Testing.Platform" From 4f53ad590a605237817440646e3cd695d77f082d Mon Sep 17 00:00:00 2001 From: Austin Aviv Date: Wed, 21 Oct 2026 23:12:51 +0530 Subject: [PATCH 966/984] fix: support reinitializing OpenApiOperation.Tags to null and custom comparers (#3116) * fix: preserve custom tag comparers and sorted sets in OpenApiOperation copy constructor Align the OpenApiOperation copy constructor with OpenApiOperation.Tags setter to preserve custom equality comparers, sorted sets, and immutable sorted sets, and add corresponding copy constructor unit tests. * refactor: deduplicate tag normalization logic into static helper Extract CopyTags static method to deduplicate tag normalization logic between OpenApiOperation.Tags setter and the copy constructor as requested in review. --- .../Models/OpenApiOperation.cs | 29 +++++----- .../Models/OpenApiOperationTests.cs | 56 +++++++++++++++++++ 2 files changed, 71 insertions(+), 14 deletions(-) diff --git a/src/Microsoft.OpenApi/Models/OpenApiOperation.cs b/src/Microsoft.OpenApi/Models/OpenApiOperation.cs index 20ce8bf53..0a79481f0 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiOperation.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiOperation.cs @@ -28,21 +28,22 @@ public ISet? Tags } set { - if (value is null) - { - _tags = null; - return; - } - _tags = value switch - { - HashSet tags when !ReferenceEquals(tags.Comparer, EqualityComparer.Default) => value, - SortedSet => value, + _tags = CopyTags(value); + } + } + + private static ISet? CopyTags(ISet? tags, bool copy = false) + { + return tags switch + { + null => null, + HashSet hashSet when !ReferenceEquals(hashSet.Comparer, EqualityComparer.Default) => copy ? new HashSet(hashSet, hashSet.Comparer) : hashSet, + SortedSet sorted => copy ? new SortedSet(sorted, sorted.Comparer) : sorted, #if NET - ImmutableSortedSet => value, + ImmutableSortedSet => tags, #endif - _ => new HashSet(value, OpenApiTagComparer.Instance), - }; - } + _ => new HashSet(tags, OpenApiTagComparer.Instance), + }; } /// @@ -139,7 +140,7 @@ public OpenApiOperation() { } public OpenApiOperation(OpenApiOperation operation) { Utils.CheckArgumentNull(operation); - Tags = operation.Tags != null ? new HashSet(operation.Tags) : null; + Tags = CopyTags(operation.Tags, copy: true); Summary = operation.Summary ?? Summary; Description = operation.Description ?? Description; ExternalDocs = operation.ExternalDocs != null ? new(operation.ExternalDocs) : null; diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs index 46e25c183..b43ef7b53 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs @@ -939,5 +939,61 @@ public void TagsSupportsImmutableSortedSets() Assert.Equal(["tagC", "tagB", "tagA"], names); Assert.IsType>(operation.Tags); } + + [Fact] + public void OpenApiOperationCopyConstructorPreservesCustomComparer() + { + var operation = new OpenApiOperation + { + Tags = new HashSet(new CaseInsensitiveOpenApiTagReferenceEqualityComparer()) + { + new("Tag1") + } + }; + + var copy = new OpenApiOperation(operation); + Assert.NotNull(copy.Tags); + Assert.False(copy.Tags.Add(new OpenApiTagReference("tag1"))); + Assert.Single(copy.Tags); + } + + [Fact] + public void OpenApiOperationCopyConstructorPreservesSortedSet() + { + var operation = new OpenApiOperation + { + Tags = new SortedSet(new DescendingOpenApiTagReferenceComparer()) + { + new("tagB"), + new("tagA"), + new("tagC"), + } + }; + + var copy = new OpenApiOperation(operation); + Assert.IsType>(copy.Tags); + var copyNames = copy.Tags.Select(t => t.Name); + Assert.Equal(["tagC", "tagB", "tagA"], copyNames); + } + + [Fact] + public void OpenApiOperationCopyConstructorPreservesImmutableSortedSet() + { + var operation = new OpenApiOperation + { + Tags = ImmutableSortedSet.Create( + new DescendingOpenApiTagReferenceComparer(), + [ + new OpenApiTagReference("tagB"), + new OpenApiTagReference("tagA"), + new OpenApiTagReference("tagC"), + ]), + }; + + var copy = new OpenApiOperation(operation); + Assert.IsType>(copy.Tags); + var copyNames = copy.Tags.Select(t => t.Name); + Assert.Equal(["tagC", "tagB", "tagA"], copyNames); + } } } From b63d6ec31bf754ced99eb6b0794665b49bf46f09 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 22 Oct 2026 05:24:22 -0400 Subject: [PATCH 967/984] chore(deps): bump actions/setup-java from 6.0.1 to 6.1.0 (#3143) Bumps [actions/setup-java](https://github.com/actions/setup-java) from 6.0.1 to 6.1.0. - [Release notes](https://github.com/actions/setup-java/releases) - [Commits](https://github.com/actions/setup-java/compare/de7274f081f381c8f8158605e0321c36c376e2e6...b843ebf9b913146b38da2eaa7aeddf76074ae1ad) --- updated-dependencies: - dependency-name: actions/setup-java dependency-version: 6.1.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/sonarcloud.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index a6954d70d..9d6e25106 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -35,7 +35,7 @@ jobs: runs-on: windows-latest steps: - name: Set up JDK 17 - uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # v6.0.1 + uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0 with: distribution: 'temurin' java-version: 17 From f633905129658c787db9e65da0ecfc9b850cdea1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 22 Oct 2026 18:08:19 -0400 Subject: [PATCH 968/984] chore(deps): bump the codeql group with 2 updates (#3144) Bumps the codeql group with 2 updates: [github/codeql-action/init](https://github.com/github/codeql-action) and [github/codeql-action/analyze](https://github.com/github/codeql-action). Updates `github/codeql-action/init` from 4.38.3 to 4.39.0 - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/codeql-action/compare/24c54180a607b1449ed407dd24f251e4e9147c8d...6f2ac81f5cd81fe351a197ba0b00d91d03cd2aee) Updates `github/codeql-action/analyze` from 4.38.3 to 4.39.0 - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/codeql-action/compare/24c54180a607b1449ed407dd24f251e4e9147c8d...6f2ac81f5cd81fe351a197ba0b00d91d03cd2aee) --- updated-dependencies: - dependency-name: github/codeql-action/init dependency-version: 4.39.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: codeql - dependency-name: github/codeql-action/analyze dependency-version: 4.39.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: codeql ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/codeql-analysis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index d7bd4b843..f76dc619c 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -34,7 +34,7 @@ jobs: - name: Initialize CodeQL id: init_codeql - uses: github/codeql-action/init@24c54180a607b1449ed407dd24f251e4e9147c8d # v4.38.3 + uses: github/codeql-action/init@6f2ac81f5cd81fe351a197ba0b00d91d03cd2aee # v4.39.0 with: queries: security-and-quality @@ -53,6 +53,6 @@ jobs: - name: Perform CodeQL Analysis id: analyze_codeql - uses: github/codeql-action/analyze@24c54180a607b1449ed407dd24f251e4e9147c8d # v4.38.3 + uses: github/codeql-action/analyze@6f2ac81f5cd81fe351a197ba0b00d91d03cd2aee # v4.39.0 # Built with ❤ by [Pipeline Foundation](https://pipeline.foundation) \ No newline at end of file From 76ea786406270d0465831e4c6d1bd50c3685a74b Mon Sep 17 00:00:00 2001 From: Hardik K Date: Fri, 23 Oct 2026 19:01:22 +0530 Subject: [PATCH 969/984] fix(models): preserve tag collection types and comparers in copy constructors (#3141) fix(models): preserve tag collection types and comparers in OpenApiDocument copy constructor --- .../Models/OpenApiDocument.cs | 29 +++++----- .../Models/OpenApiDocumentTests.cs | 56 +++++++++++++++++++ 2 files changed, 71 insertions(+), 14 deletions(-) diff --git a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs index 03086600d..de2bb9d16 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs @@ -87,21 +87,22 @@ public ISet? Tags } set { - if (value is null) - { - _tags = null; - return; - } - _tags = value switch - { - HashSet tags when tags.Comparer != EqualityComparer.Default => value, - SortedSet => value, + _tags = CopyTags(value); + } + } + + private static ISet? CopyTags(ISet? tags, bool copy = false) + { + return tags switch + { + null => null, + HashSet hashSet when !ReferenceEquals(hashSet.Comparer, EqualityComparer.Default) => copy ? new HashSet(hashSet, hashSet.Comparer) : hashSet, + SortedSet sorted => copy ? new SortedSet(sorted, sorted.Comparer) : sorted, #if NET - ImmutableSortedSet => value, + ImmutableSortedSet => tags, #endif - _ => new HashSet(value, OpenApiTagComparer.Instance), - }; - } + _ => new HashSet(tags, OpenApiTagComparer.Instance), + }; } /// @@ -147,7 +148,7 @@ public OpenApiDocument(OpenApiDocument? document) Webhooks = document?.Webhooks != null ? new Dictionary(document.Webhooks) : null; Components = document?.Components != null ? new(document?.Components) : null; Security = document?.Security != null ? [.. document.Security] : null; - Tags = document?.Tags != null ? new HashSet(document.Tags, OpenApiTagComparer.Instance) : null; + Tags = CopyTags(document?.Tags, copy: true); ExternalDocs = document?.ExternalDocs != null ? new(document.ExternalDocs) : null; Extensions = document?.Extensions != null ? new Dictionary(document.Extensions) : null; Metadata = document?.Metadata != null ? new Dictionary(document.Metadata) : null; diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs index 8b4629664..3abfb42fd 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs @@ -2214,6 +2214,62 @@ public void TagsSupportsImmutableSortedSets() Assert.IsType>(document.Tags); } + [Fact] + public void OpenApiDocumentCopyConstructorPreservesCustomComparer() + { + var document = new OpenApiDocument + { + Tags = new HashSet(new CaseInsensitiveOpenApiTagEqualityComparer()) + { + new() { Name = "Tag1" } + } + }; + + var copy = new OpenApiDocument(document); + Assert.NotNull(copy.Tags); + Assert.False(copy.Tags.Add(new OpenApiTag { Name = "tag1" })); + Assert.Single(copy.Tags); + } + + [Fact] + public void OpenApiDocumentCopyConstructorPreservesSortedSet() + { + var document = new OpenApiDocument + { + Tags = new SortedSet(new DescendingOpenApiTagComparer()) + { + new() { Name = "tagB" }, + new() { Name = "tagA" }, + new() { Name = "tagC" }, + } + }; + + var copy = new OpenApiDocument(document); + Assert.IsType>(copy.Tags); + var copyNames = copy.Tags.Select(t => t.Name); + Assert.Equal(["tagC", "tagB", "tagA"], copyNames); + } + + [Fact] + public void OpenApiDocumentCopyConstructorPreservesImmutableSortedSet() + { + var document = new OpenApiDocument + { + Tags = ImmutableSortedSet.Create( + new DescendingOpenApiTagComparer(), + [ + new OpenApiTag { Name = "tagB" }, + new OpenApiTag { Name = "tagA" }, + new OpenApiTag { Name = "tagC" }, + ]), + }; + + var copy = new OpenApiDocument(document); + Assert.IsType>(copy.Tags); + var copyNames = copy.Tags.Select(t => t.Name); + Assert.Equal(["tagC", "tagB", "tagA"], copyNames); + } + public static TheoryData OpenApiSpecVersions() { var values = new TheoryData(); From b0a6859be48927746726e967f578f370cd756f35 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 24 Oct 2026 06:46:08 -0400 Subject: [PATCH 970/984] Bump Verify.XunitV3 from 33.3.3 to 33.3.4 (#3146) --- updated-dependencies: - dependency-name: Verify.XunitV3 dependency-version: 33.3.4 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- 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 b77085ac2..1ffa3063a 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -14,7 +14,7 @@ - + From e41f0e82ac1be5c58e036195414d10b9d9f7efba Mon Sep 17 00:00:00 2001 From: Hardik K Date: Wed, 28 Oct 2026 01:03:09 +0530 Subject: [PATCH 971/984] fix(v2): map OpenAPI 2.0 response schema type file to binary format (#3150) * test(v2): add unit test for OpenAPI 2.0 schema type file mapping to binary format * fix(v2): set format binary when reading OpenAPI 2.0 schema with type file * test(v2): add response schema integration test for type file * docs(v2): document OpenAPI 2.0 file type to binary format mapping in schema deserializer * test(v2): parse enclosing operation with produces to populate response content schema --- .../Reader/V2/OpenApiSchemaDeserializer.cs | 7 +++- .../V2Tests/OpenApiSchemaTests.cs | 37 ++++++++++++++++++- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi/Reader/V2/OpenApiSchemaDeserializer.cs b/src/Microsoft.OpenApi/Reader/V2/OpenApiSchemaDeserializer.cs index 9e181fdcd..2f3a4dcec 100644 --- a/src/Microsoft.OpenApi/Reader/V2/OpenApiSchemaDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V2/OpenApiSchemaDeserializer.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System; @@ -170,6 +170,11 @@ internal static partial class OpenApiV2Deserializer if (type != null) { o.Type = type.ToJsonSchemaType(); + // OpenAPI 2.0 response schema allows type: file, which maps to format: binary in OpenAPI 3.x + if ("file".Equals(type, StringComparison.OrdinalIgnoreCase)) + { + o.Format = "binary"; + } } } }, diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSchemaTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSchemaTests.cs index cbbde4b70..0f02c3743 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSchemaTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSchemaTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System.Collections.Generic; @@ -186,5 +186,40 @@ public async Task SerializeSchemaWithOnlyNullableShouldSucceed() Assert.Equal(expected.MakeLineBreaksEnvironmentNeutral(), schemaString.MakeLineBreaksEnvironmentNeutral()); } + + [Fact] + public void ParseSchemaWithTypeFileShouldSetTypeStringAndFormatBinary() + { + // Arrange + var node = JsonNode.Parse("{\"type\": \"file\"}"); + + // Act + var schema = OpenApiV2Deserializer.LoadSchema(node, new(), new ParsingContext(new())); + + // Assert + Assert.NotNull(schema); + Assert.Equal(JsonSchemaType.String, schema.Type); + Assert.Equal("binary", schema.Format); + } + + [Fact] + public void ParseResponseSchemaWithTypeFileShouldSetTypeStringAndFormatBinary() + { + // Arrange + var node = JsonNode.Parse("{\"produces\": [\"application/octet-stream\"], \"responses\": {\"200\": {\"description\": \"File response\", \"schema\": {\"type\": \"file\"}}}}"); + + // Act + var operation = OpenApiV2Deserializer.LoadOperation(node, new(), new ParsingContext(new())); + + // Assert + Assert.NotNull(operation); + Assert.NotNull(operation.Responses); + var response = Assert.IsType(operation.Responses["200"]); + Assert.NotNull(response.Content); + var mediaType = Assert.Single(response.Content.Values); + Assert.NotNull(mediaType.Schema); + Assert.Equal(JsonSchemaType.String, mediaType.Schema.Type); + Assert.Equal("binary", mediaType.Schema.Format); + } } } From 47a130b88d1def7db31048172a8d81c20685e6c3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 28 Oct 2026 18:10:44 -0400 Subject: [PATCH 972/984] chore(deps): bump the codeql group with 2 updates (#3152) Bumps the codeql group with 2 updates: [github/codeql-action/init](https://github.com/github/codeql-action) and [github/codeql-action/analyze](https://github.com/github/codeql-action). Updates `github/codeql-action/init` from 4.39.0 to 4.39.1 - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/codeql-action/compare/6f2ac81f5cd81fe351a197ba0b00d91d03cd2aee...9b3254085494b55a0f7c4c2b3d2d52cc712ce370) Updates `github/codeql-action/analyze` from 4.39.0 to 4.39.1 - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/codeql-action/compare/6f2ac81f5cd81fe351a197ba0b00d91d03cd2aee...9b3254085494b55a0f7c4c2b3d2d52cc712ce370) --- updated-dependencies: - dependency-name: github/codeql-action/init dependency-version: 4.39.1 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: codeql - dependency-name: github/codeql-action/analyze dependency-version: 4.39.1 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: codeql ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/codeql-analysis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index f76dc619c..819b50e4f 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -34,7 +34,7 @@ jobs: - name: Initialize CodeQL id: init_codeql - uses: github/codeql-action/init@6f2ac81f5cd81fe351a197ba0b00d91d03cd2aee # v4.39.0 + uses: github/codeql-action/init@9b3254085494b55a0f7c4c2b3d2d52cc712ce370 # v4.39.1 with: queries: security-and-quality @@ -53,6 +53,6 @@ jobs: - name: Perform CodeQL Analysis id: analyze_codeql - uses: github/codeql-action/analyze@6f2ac81f5cd81fe351a197ba0b00d91d03cd2aee # v4.39.0 + uses: github/codeql-action/analyze@9b3254085494b55a0f7c4c2b3d2d52cc712ce370 # v4.39.1 # Built with ❤ by [Pipeline Foundation](https://pipeline.foundation) \ No newline at end of file From dd08a6d07239a692dd887e2404ea6e7649d9d35f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Nov 2026 21:33:42 +0000 Subject: [PATCH 973/984] chore(deps): bump dotnet-sdk from 10.0.402 to 10.0.403 (#3156) Bumps [dotnet-sdk](https://github.com/dotnet/sdk) from 10.0.402 to 10.0.403. - [Release notes](https://github.com/dotnet/sdk/releases) - [Commits](https://github.com/dotnet/sdk/compare/v10.0.402...v10.0.403) --- updated-dependencies: - dependency-name: dotnet-sdk dependency-version: 10.0.403 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index c92eedfeb..c6880be64 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "10.0.402" + "version": "10.0.403" }, "test": { "runner": "Microsoft.Testing.Platform" From 7fa9b61e0a4734c0af19e32bc2277529e6b84d0d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Nov 2026 16:34:40 -0500 Subject: [PATCH 974/984] Bump the microsoftextensions group with 5 updates (#3157) Bumps Microsoft.Extensions.DependencyInjection from 10.0.13 to 10.0.14 Bumps Microsoft.Extensions.Logging from 10.0.13 to 10.0.14 Bumps Microsoft.Extensions.Logging.Console from 10.0.13 to 10.0.14 Bumps Microsoft.Extensions.Logging.Debug from 10.0.13 to 10.0.14 Bumps System.Text.Json from 10.0.13 to 10.0.14 --- updated-dependencies: - dependency-name: Microsoft.Extensions.DependencyInjection dependency-version: 10.0.14 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: microsoftextensions - dependency-name: Microsoft.Extensions.Logging dependency-version: 10.0.14 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: microsoftextensions - dependency-name: Microsoft.Extensions.Logging.Console dependency-version: 10.0.14 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: microsoftextensions - dependency-name: System.Text.Json dependency-version: 10.0.14 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: microsoftextensions - dependency-name: Microsoft.Extensions.Logging.Debug dependency-version: 10.0.14 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: microsoftextensions ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- performance/resultsComparer/resultsComparer.csproj | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/performance/resultsComparer/resultsComparer.csproj b/performance/resultsComparer/resultsComparer.csproj index 453944872..38b16b554 100644 --- a/performance/resultsComparer/resultsComparer.csproj +++ b/performance/resultsComparer/resultsComparer.csproj @@ -8,12 +8,12 @@ - - - - + + + + - + From 113803cbc13defe55975292f374e2eaeea8d288f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Nov 2026 21:35:44 +0000 Subject: [PATCH 975/984] Bump Microsoft.SourceLink.GitHub from 10.0.402 to 10.0.403 (#3158) --- updated-dependencies: - dependency-name: Microsoft.SourceLink.GitHub dependency-version: 10.0.403 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 063a25831..5eb725c09 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -21,6 +21,6 @@ true - + \ No newline at end of file From 1bf657326b18c01e1cf4cd4205c1eaa09b6bfd30 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 3 Nov 2026 17:23:30 -0500 Subject: [PATCH 976/984] Bump the testing group with 2 updates (#3161) Bumps Microsoft.Testing.Extensions.AzureDevOpsReport from 2.5.1 to 2.5.2 Bumps Microsoft.Testing.Extensions.GitHubActionsReport from 2.5.1 to 2.5.2 --- updated-dependencies: - dependency-name: Microsoft.Testing.Extensions.AzureDevOpsReport dependency-version: 2.5.2 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: testing - dependency-name: Microsoft.Testing.Extensions.GitHubActionsReport dependency-version: 2.5.2 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: testing ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .../Microsoft.OpenApi.Readers.Tests.csproj | 4 ++-- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 4 ++-- 2 files changed, 4 insertions(+), 4 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 0c6d93ee0..80dc75811 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj +++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj @@ -18,8 +18,8 @@ - - + + diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 1ffa3063a..c0dfc5d1d 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -11,8 +11,8 @@ - - + + From a68f8bef1359f4cb3c4734673b0fa3c332659a5b Mon Sep 17 00:00:00 2001 From: Hardik K Date: Fri, 6 Nov 2026 20:24:36 +0530 Subject: [PATCH 977/984] fix(models): preserve specification extensions in OpenApiPaths and OpenApiResponses copy constructors (#3162) * fix(models): preserve extensions in OpenApiPaths copy constructor Signed-off-by: Hardik K * test(models): add unit tests for OpenApiPaths copy constructor extensions Signed-off-by: Hardik K * test(models): verify OpenApiDocument copy constructor preserves Paths extensions Signed-off-by: Hardik K * fix(models): preserve extensions in OpenApiResponses copy constructor Signed-off-by: Hardik K * test(models): add unit tests for OpenApiResponses copy constructor extensions Signed-off-by: Hardik K * test(models): verify OpenApiOperation copy constructor preserves Responses extensions Signed-off-by: Hardik K * test(models): add edge case tests for null and empty extensions in Paths and Responses copy constructors Signed-off-by: Hardik K * docs(models): update XML documentation on OpenApiPaths and OpenApiResponses copy constructors Signed-off-by: Hardik K --------- Signed-off-by: Hardik K --- src/Microsoft.OpenApi/Models/OpenApiPaths.cs | 11 +- .../Models/OpenApiResponses.cs | 14 ++- .../Models/OpenApiDocumentTests.cs | 34 +++++- .../Models/OpenApiOperationTests.cs | 32 ++++++ .../Models/OpenApiPathsTests.cs | 101 ++++++++++++++++++ .../Models/OpenApiResponsesTests.cs | 101 ++++++++++++++++++ 6 files changed, 284 insertions(+), 9 deletions(-) create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiPathsTests.cs create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiResponsesTests.cs diff --git a/src/Microsoft.OpenApi/Models/OpenApiPaths.cs b/src/Microsoft.OpenApi/Models/OpenApiPaths.cs index 1aa163e3c..d79c95320 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiPaths.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiPaths.cs @@ -1,6 +1,8 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. +using System.Collections.Generic; + namespace Microsoft.OpenApi { /// @@ -14,12 +16,13 @@ public class OpenApiPaths : OpenApiExtensibleDictionary public OpenApiPaths() { } /// - /// Initializes a copy of object + /// Initializes a copy of object. /// /// The . /// - /// This creates a shallow copy, the path items are the same reference as in the provided parameter. + /// This creates a shallow copy; the path items are the same reference as in the provided parameter, + /// and specification extensions are copied into a new dictionary. /// - public OpenApiPaths(OpenApiPaths paths) : base(dictionary: paths) { } + public OpenApiPaths(OpenApiPaths paths) : base(dictionary: paths, extensions: paths?.Extensions != null ? new Dictionary(paths.Extensions) : null) { } } } diff --git a/src/Microsoft.OpenApi/Models/OpenApiResponses.cs b/src/Microsoft.OpenApi/Models/OpenApiResponses.cs index 63a144a2a..f510c9cd5 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiResponses.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiResponses.cs @@ -1,6 +1,8 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. +using System.Collections.Generic; + namespace Microsoft.OpenApi { /// @@ -14,9 +16,13 @@ public class OpenApiResponses : OpenApiExtensibleDictionary public OpenApiResponses() { } /// - /// Initializes a copy of object + /// Initializes a copy of object. /// - /// The - public OpenApiResponses(OpenApiResponses openApiResponses) : base(dictionary: openApiResponses) { } + /// The . + /// + /// This creates a shallow copy; the responses are the same reference as in the provided parameter, + /// and specification extensions are copied into a new dictionary. + /// + public OpenApiResponses(OpenApiResponses openApiResponses) : base(dictionary: openApiResponses, extensions: openApiResponses?.Extensions != null ? new Dictionary(openApiResponses.Extensions) : null) { } } } diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs index 3abfb42fd..774d9ff2a 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System; @@ -2753,5 +2753,37 @@ public void GetOperationById_ThrowsOnNullOrEmptyId() Assert.Throws(() => doc.GetOperationById(null!)); Assert.Throws(() => doc.GetOperationById(string.Empty)); } + + [Fact] + public void OpenApiDocumentCopyConstructorPreservesPathsExtensions() + { + // Arrange + var document = new OpenApiDocument + { + Info = new OpenApiInfo { Title = "Test API", Version = "1.0.0" }, + Paths = new OpenApiPaths + { + ["/items"] = new OpenApiPathItem(), + Extensions = new Dictionary + { + ["x-paths-summary"] = new JsonNodeExtension("Paths level extension") + } + } + }; + + // Act + var copy = new OpenApiDocument(document); + + // Assert + Assert.NotNull(copy.Paths); + Assert.NotNull(copy.Paths.Extensions); + Assert.Single(copy.Paths.Extensions); + Assert.True(copy.Paths.Extensions.ContainsKey("x-paths-summary")); + + // Verify isolation + copy.Paths.Extensions["x-isolated"] = new JsonNodeExtension("isolated"); + Assert.Single(document.Paths.Extensions); + Assert.False(document.Paths.Extensions.ContainsKey("x-isolated")); + } } } diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs index b43ef7b53..8a9af17cc 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs @@ -995,5 +995,37 @@ public void OpenApiOperationCopyConstructorPreservesImmutableSortedSet() var copyNames = copy.Tags.Select(t => t.Name); Assert.Equal(["tagC", "tagB", "tagA"], copyNames); } + + [Fact] + public void OpenApiOperationCopyConstructorPreservesResponsesExtensions() + { + // Arrange + var operation = new OpenApiOperation + { + OperationId = "getItem", + Responses = new OpenApiResponses + { + ["200"] = new OpenApiResponse { Description = "Success" }, + Extensions = new Dictionary + { + ["x-responses-meta"] = new JsonNodeExtension("Metadata for responses") + } + } + }; + + // Act + var copy = new OpenApiOperation(operation); + + // Assert + Assert.NotNull(copy.Responses); + Assert.NotNull(copy.Responses.Extensions); + Assert.Single(copy.Responses.Extensions); + Assert.True(copy.Responses.Extensions.ContainsKey("x-responses-meta")); + + // Verify isolation + copy.Responses.Extensions["x-isolated"] = new JsonNodeExtension("isolated"); + Assert.Single(operation.Responses.Extensions); + Assert.False(operation.Responses.Extensions.ContainsKey("x-isolated")); + } } } diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiPathsTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiPathsTests.cs new file mode 100644 index 000000000..c4ebc20df --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiPathsTests.cs @@ -0,0 +1,101 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. + +using System.Collections.Generic; +using Xunit; + +namespace Microsoft.OpenApi.Tests.Models +{ + [Collection("DefaultSettings")] + public class OpenApiPathsTests + { + [Fact] + public void CopyConstructorCopiesExtensions() + { + // Arrange + var paths = new OpenApiPaths + { + ["/users"] = new OpenApiPathItem(), + Extensions = new Dictionary + { + ["x-custom-path"] = new JsonNodeExtension("custom-value"), + ["x-rate-limit"] = new JsonNodeExtension(100), + } + }; + + // Act + var copy = new OpenApiPaths(paths); + + // Assert + Assert.NotNull(copy.Extensions); + Assert.Equal(2, copy.Extensions.Count); + Assert.True(copy.Extensions.ContainsKey("x-custom-path")); + Assert.True(copy.Extensions.ContainsKey("x-rate-limit")); + } + + [Fact] + public void CopyConstructorIsolatesExtensionsDictionary() + { + // Arrange + var paths = new OpenApiPaths + { + Extensions = new Dictionary + { + ["x-original"] = new JsonNodeExtension("original") + } + }; + + // Act + var copy = new OpenApiPaths(paths); + copy.Extensions["x-copy-only"] = new JsonNodeExtension("copy"); + + // Assert + Assert.Equal(2, copy.Extensions.Count); + Assert.Single(paths.Extensions); + Assert.False(paths.Extensions.ContainsKey("x-copy-only")); + } + + [Fact] + public void CopyConstructorWithNullPathsInitializesEmptyExtensions() + { + // Act + var copy = new OpenApiPaths(null!); + + // Assert + Assert.NotNull(copy.Extensions); + Assert.Empty(copy.Extensions); + Assert.Empty(copy); + } + + [Fact] + public void CopyConstructorWithNullExtensionsInitializesEmptyExtensions() + { + // Arrange + var paths = new OpenApiPaths { Extensions = null }; + + // Act + var copy = new OpenApiPaths(paths); + + // Assert + Assert.NotNull(copy.Extensions); + Assert.Empty(copy.Extensions); + } + + [Fact] + public void CopyConstructorWithEmptyExtensionsInitializesEmptyExtensions() + { + // Arrange + var paths = new OpenApiPaths + { + Extensions = new Dictionary() + }; + + // Act + var copy = new OpenApiPaths(paths); + + // Assert + Assert.NotNull(copy.Extensions); + Assert.Empty(copy.Extensions); + } + } +} diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiResponsesTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponsesTests.cs new file mode 100644 index 000000000..35390ccb4 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponsesTests.cs @@ -0,0 +1,101 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. + +using System.Collections.Generic; +using Xunit; + +namespace Microsoft.OpenApi.Tests.Models +{ + [Collection("DefaultSettings")] + public class OpenApiResponsesTests + { + [Fact] + public void CopyConstructorCopiesExtensions() + { + // Arrange + var responses = new OpenApiResponses + { + ["200"] = new OpenApiResponse { Description = "OK" }, + Extensions = new Dictionary + { + ["x-response-notes"] = new JsonNodeExtension("all-responses-note"), + ["x-default-code"] = new JsonNodeExtension("200"), + } + }; + + // Act + var copy = new OpenApiResponses(responses); + + // Assert + Assert.NotNull(copy.Extensions); + Assert.Equal(2, copy.Extensions.Count); + Assert.True(copy.Extensions.ContainsKey("x-response-notes")); + Assert.True(copy.Extensions.ContainsKey("x-default-code")); + } + + [Fact] + public void CopyConstructorIsolatesExtensionsDictionary() + { + // Arrange + var responses = new OpenApiResponses + { + Extensions = new Dictionary + { + ["x-original"] = new JsonNodeExtension("original") + } + }; + + // Act + var copy = new OpenApiResponses(responses); + copy.Extensions["x-copy-only"] = new JsonNodeExtension("copy"); + + // Assert + Assert.Equal(2, copy.Extensions.Count); + Assert.Single(responses.Extensions); + Assert.False(responses.Extensions.ContainsKey("x-copy-only")); + } + + [Fact] + public void CopyConstructorWithNullResponsesInitializesEmptyExtensions() + { + // Act + var copy = new OpenApiResponses(null!); + + // Assert + Assert.NotNull(copy.Extensions); + Assert.Empty(copy.Extensions); + Assert.Empty(copy); + } + + [Fact] + public void CopyConstructorWithNullExtensionsInitializesEmptyExtensions() + { + // Arrange + var responses = new OpenApiResponses { Extensions = null }; + + // Act + var copy = new OpenApiResponses(responses); + + // Assert + Assert.NotNull(copy.Extensions); + Assert.Empty(copy.Extensions); + } + + [Fact] + public void CopyConstructorWithEmptyExtensionsInitializesEmptyExtensions() + { + // Arrange + var responses = new OpenApiResponses + { + Extensions = new Dictionary() + }; + + // Act + var copy = new OpenApiResponses(responses); + + // Assert + Assert.NotNull(copy.Extensions); + Assert.Empty(copy.Extensions); + } + } +} From 69dcce2a8855ca424466b0bdfd66c6db62c8594c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Nov 2026 18:45:43 -0500 Subject: [PATCH 978/984] chore(deps): bump actions/setup-dotnet from 6.0.0 to 6.1.0 (#3166) Bumps [actions/setup-dotnet](https://github.com/actions/setup-dotnet) from 6.0.0 to 6.1.0. - [Release notes](https://github.com/actions/setup-dotnet/releases) - [Commits](https://github.com/actions/setup-dotnet/compare/a98b56852c35b8e3190ac28c8c2271da59106c68...0f4a354dd5547a28c70b7853dbd95d5b67886e73) --- updated-dependencies: - dependency-name: actions/setup-dotnet dependency-version: 6.1.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci-cd.yml | 12 ++++++------ .github/workflows/codeql-analysis.yml | 4 ++-- .github/workflows/sonarcloud.yml | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index b77f7d85e..19ba8aa6b 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -18,12 +18,12 @@ jobs: GITHUB_RUN_NUMBER: ${{ github.run_number }} steps: - name: Setup .NET 8 - uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0 + uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0 with: dotnet-version: 8.x - name: Setup .NET 10 - uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0 + uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0 with: dotnet-version: 10.x @@ -83,12 +83,12 @@ jobs: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Setup .NET 8 - uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0 + uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0 with: dotnet-version: 8.x - name: Setup .NET 10 - uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0 + uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0 with: dotnet-version: 10.x @@ -105,12 +105,12 @@ jobs: uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Setup .NET 8 - uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0 + uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0 with: dotnet-version: 8.x - name: Setup .NET 10 - uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0 + uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0 with: dotnet-version: 10.x diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 819b50e4f..538f2dadc 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -23,12 +23,12 @@ jobs: uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Setup .NET 8 - uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0 + uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0 with: dotnet-version: 8.0.x - name: Setup .NET 10 - uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0 + uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0 with: dotnet-version: 10.0.x diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 9d6e25106..e1bbb2fd2 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -40,11 +40,11 @@ jobs: distribution: 'temurin' java-version: 17 - name: Setup .NET 8 - uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0 + uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0 with: dotnet-version: 8.0.x - name: Setup .NET 10 - uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0 + uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0 with: dotnet-version: 10.0.x - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 From 3501cf4a984b259e1cf50e4767cdbebe76b6c61c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 10 Nov 2026 18:28:46 -0500 Subject: [PATCH 979/984] chore(deps): bump the codeql group with 2 updates (#3167) Bumps the codeql group with 2 updates: [github/codeql-action/init](https://github.com/github/codeql-action) and [github/codeql-action/analyze](https://github.com/github/codeql-action). Updates `github/codeql-action/init` from 4.39.1 to 4.39.2 - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/codeql-action/compare/9b3254085494b55a0f7c4c2b3d2d52cc712ce370...1fc58d04a4d4374f921bdac573c3811c240f9c26) Updates `github/codeql-action/analyze` from 4.39.1 to 4.39.2 - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/codeql-action/compare/9b3254085494b55a0f7c4c2b3d2d52cc712ce370...1fc58d04a4d4374f921bdac573c3811c240f9c26) --- updated-dependencies: - dependency-name: github/codeql-action/init dependency-version: 4.39.2 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: codeql - dependency-name: github/codeql-action/analyze dependency-version: 4.39.2 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: codeql ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/codeql-analysis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 538f2dadc..89064652a 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -34,7 +34,7 @@ jobs: - name: Initialize CodeQL id: init_codeql - uses: github/codeql-action/init@9b3254085494b55a0f7c4c2b3d2d52cc712ce370 # v4.39.1 + uses: github/codeql-action/init@1fc58d04a4d4374f921bdac573c3811c240f9c26 # v4.39.2 with: queries: security-and-quality @@ -53,6 +53,6 @@ jobs: - name: Perform CodeQL Analysis id: analyze_codeql - uses: github/codeql-action/analyze@9b3254085494b55a0f7c4c2b3d2d52cc712ce370 # v4.39.1 + uses: github/codeql-action/analyze@1fc58d04a4d4374f921bdac573c3811c240f9c26 # v4.39.2 # Built with ❤ by [Pipeline Foundation](https://pipeline.foundation) \ No newline at end of file From c238f37d225a34b1da49bbeb153a7e1a68906e3f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 11 Nov 2026 16:47:08 -0500 Subject: [PATCH 980/984] chore(deps): bump the codeql group with 2 updates (#3168) Bumps the codeql group with 2 updates: [github/codeql-action/init](https://github.com/github/codeql-action) and [github/codeql-action/analyze](https://github.com/github/codeql-action). Updates `github/codeql-action/init` from 4.39.2 to 4.39.3 - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/codeql-action/compare/1fc58d04a4d4374f921bdac573c3811c240f9c26...33d7b85da1a04171e211befe2c739303b9a4c066) Updates `github/codeql-action/analyze` from 4.39.2 to 4.39.3 - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/codeql-action/compare/1fc58d04a4d4374f921bdac573c3811c240f9c26...33d7b85da1a04171e211befe2c739303b9a4c066) --- updated-dependencies: - dependency-name: github/codeql-action/init dependency-version: 4.39.3 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: codeql - dependency-name: github/codeql-action/analyze dependency-version: 4.39.3 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: codeql ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/codeql-analysis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 89064652a..31a017681 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -34,7 +34,7 @@ jobs: - name: Initialize CodeQL id: init_codeql - uses: github/codeql-action/init@1fc58d04a4d4374f921bdac573c3811c240f9c26 # v4.39.2 + uses: github/codeql-action/init@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3 with: queries: security-and-quality @@ -53,6 +53,6 @@ jobs: - name: Perform CodeQL Analysis id: analyze_codeql - uses: github/codeql-action/analyze@1fc58d04a4d4374f921bdac573c3811c240f9c26 # v4.39.2 + uses: github/codeql-action/analyze@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3 # Built with ❤ by [Pipeline Foundation](https://pipeline.foundation) \ No newline at end of file From 123d928057eee6221b841964268d8975bb27b91b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 11 Nov 2026 16:47:29 -0500 Subject: [PATCH 981/984] chore(deps): bump actions/setup-java from 6.1.0 to 6.2.0 (#3169) Bumps [actions/setup-java](https://github.com/actions/setup-java) from 6.1.0 to 6.2.0. - [Release notes](https://github.com/actions/setup-java/releases) - [Commits](https://github.com/actions/setup-java/compare/b843ebf9b913146b38da2eaa7aeddf76074ae1ad...77dd5b2ce225ea11469928ac317850245a74ae78) --- updated-dependencies: - dependency-name: actions/setup-java dependency-version: 6.2.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/sonarcloud.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index e1bbb2fd2..a50a038c6 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -35,7 +35,7 @@ jobs: runs-on: windows-latest steps: - name: Set up JDK 17 - uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0 + uses: actions/setup-java@77dd5b2ce225ea11469928ac317850245a74ae78 # v6.2.0 with: distribution: 'temurin' java-version: 17 From d8f20e829bc5cabd8097475f9243890e800e7de5 Mon Sep 17 00:00:00 2001 From: Hardik K Date: Fri, 13 Nov 2026 21:15:48 +0530 Subject: [PATCH 982/984] fix(v3): retain full JSON pointer path on OpenAPI 3.0 schema references (#3155) * fix(v3): retain full JSON pointer path on OpenAPI 3.0 schema references * test(v3): add unit test for component property schema reference in OpenAPI 3.0 * test(v3): add regression test for nested component subschema references in OpenAPI 3.0 --- .../Reader/V3/OpenApiSchemaDeserializer.cs | 4 +- .../V3Tests/OpenApiSubschemaReferenceTests.cs | 64 +++++++++++++++++++ 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSubschemaReferenceTests.cs diff --git a/src/Microsoft.OpenApi/Reader/V3/OpenApiSchemaDeserializer.cs b/src/Microsoft.OpenApi/Reader/V3/OpenApiSchemaDeserializer.cs index 7bb9327b6..22c7bf792 100644 --- a/src/Microsoft.OpenApi/Reader/V3/OpenApiSchemaDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V3/OpenApiSchemaDeserializer.cs @@ -397,7 +397,9 @@ public static IOpenApiSchema LoadSchema(JsonNode node, OpenApiDocument hostDocum if (pointer != null) { var reference = GetReferenceIdAndExternalResource(pointer); - return new OpenApiSchemaReference(reference.Item1, hostDocument, reference.Item2); + var result = new OpenApiSchemaReference(reference.Item1, hostDocument, reference.Item2); + result.Reference.SetJsonPointerPath(pointer, context.GetLocation()); + return result; } var schema = new OpenApiSchema(); diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSubschemaReferenceTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSubschemaReferenceTests.cs new file mode 100644 index 000000000..f5cb4f142 --- /dev/null +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSubschemaReferenceTests.cs @@ -0,0 +1,64 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. + +using Microsoft.OpenApi; +using Microsoft.OpenApi.Reader; +using Microsoft.OpenApi.Tests; +using Xunit; + +namespace Microsoft.OpenApi.Readers.Tests.V3Tests +{ + [Collection("DefaultSettings")] + public class OpenApiSubschemaReferenceTests + { + private const string Document = @" +openapi: 3.0.3 +info: + title: Subschema references + version: 1.0.0 +paths: {} +components: + schemas: + User: + type: object + properties: + name: + type: string + address: + type: object + properties: + city: + type: string + name: + type: integer + UserName: + $ref: '#/components/schemas/User/properties/name' + UserCity: + $ref: '#/components/schemas/User/properties/address/properties/city' +"; + + [Fact] + public void ReferenceToComponentPropertyResolvesToThatProperty() + { + var document = OpenApiDocument.Parse(Document, "yaml", SettingsFixture.ReaderSettings).Document; + + var userName = Assert.IsType(document.Components.Schemas["UserName"]); + + Assert.NotNull(userName.Target); + Assert.Equal(JsonSchemaType.String, userName.Target.Type); + Assert.Equal("#/components/schemas/User/properties/name", userName.Reference.ReferenceV3); + } + + [Fact] + public void ReferenceToNestedComponentPropertyResolvesToThatProperty() + { + var document = OpenApiDocument.Parse(Document, "yaml", SettingsFixture.ReaderSettings).Document; + + var userCity = Assert.IsType(document.Components.Schemas["UserCity"]); + + Assert.NotNull(userCity.Target); + Assert.Equal(JsonSchemaType.String, userCity.Target.Type); + Assert.Equal("#/components/schemas/User/properties/address/properties/city", userCity.Reference.ReferenceV3); + } + } +} From d14d0a1344c8ce2c425c800c99ba584c04a50377 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Fri, 13 Nov 2026 13:47:56 -0500 Subject: [PATCH 983/984] fix(reader): reduce reference parsing memory allocations (#3171) * fix(reader): balance example locations and defer reference paths Restore parsing locations after named examples, including exception paths, and construct locations only when relative reference resolution requires them. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: dc47aa82-c449-43a1-8a70-c4f3c464ae51 * fix(reader): apply location optimizations to OpenAPI 3.2 Extend the main-branch port with balanced example scopes, lazy reference locations, and OpenAPI 3.2 regression coverage. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: dc47aa82-c449-43a1-8a70-c4f3c464ae51 * chore(benchmark): refresh main performance reports Regenerate all description and empty-model benchmark reports after porting the reference allocation fixes to main. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: dc47aa82-c449-43a1-8a70-c4f3c464ae51 --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: dc47aa82-c449-43a1-8a70-c4f3c464ae51 --- .../performance.Descriptions-report-github.md | 26 ++-- .../performance.Descriptions-report.csv | 12 +- .../performance.Descriptions-report.html | 26 ++-- .../performance.Descriptions-report.json | 2 +- .../performance.EmptyModels-report-github.md | 70 +++++------ .../performance.EmptyModels-report.csv | 56 ++++----- .../performance.EmptyModels-report.html | 70 +++++------ .../performance.EmptyModels-report.json | 2 +- .../Models/BaseOpenApiReference.cs | 4 +- .../Reader/V3/OpenApiSchemaDeserializer.cs | 2 +- .../Reader/V3/OpenApiV3Deserializer.cs | 22 +++- .../Reader/V31/OpenApiSchemaDeserializer.cs | 6 +- .../Reader/V31/OpenApiV31Deserializer.cs | 22 +++- .../Reader/V32/OpenApiSchemaDeserializer.cs | 6 +- .../Reader/V32/OpenApiV32Deserializer.cs | 22 +++- .../ParsingContextTests.cs | 116 ++++++++++++++++++ .../V31Tests/OpenApiDynamicRefTests.cs | 2 +- .../V32Tests/OpenApiDynamicRefTests.cs | 2 +- 18 files changed, 308 insertions(+), 160 deletions(-) diff --git a/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.Descriptions-report-github.md b/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.Descriptions-report-github.md index 95726f79a..2979e8160 100644 --- a/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.Descriptions-report-github.md +++ b/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.Descriptions-report-github.md @@ -1,20 +1,20 @@ ``` -BenchmarkDotNet v0.15.8, Linux Ubuntu 24.04.4 LTS (Noble Numbat) -AMD EPYC 7763 2.45GHz, 1 CPU, 4 logical and 2 physical cores -.NET SDK 10.0.400 - [Host] : .NET 8.0.30 (8.0.30, 8.0.3026.36720), X64 RyuJIT x86-64-v3 - ShortRun : .NET 8.0.30 (8.0.30, 8.0.3026.36720), X64 RyuJIT x86-64-v3 +BenchmarkDotNet v0.15.8, Windows 11 (10.0.26300.9711) +Snapdragon X 12-core X1E80100 3.40 GHz (Max: 3.42GHz), 1 CPU, 12 logical and 12 physical cores +.NET SDK 10.0.403 + [Host] : .NET 8.0.34 (8.0.34, 8.0.3426.52217), Arm64 RyuJIT armv8.0-a + ShortRun : .NET 8.0.34 (8.0.34, 8.0.3426.52217), Arm64 RyuJIT armv8.0-a Job=ShortRun IterationCount=3 LaunchCount=1 WarmupCount=3 ``` -| Method | Mean | Error | StdDev | Gen0 | Gen1 | Gen2 | Allocated | -|------------- |---------------:|--------------:|-------------:|-----------:|-----------:|----------:|-------------:| -| PetStoreYaml | 569.0 μs | 108.17 μs | 5.93 μs | 19.5313 | - | - | 327.8 KB | -| PetStoreJson | 250.8 μs | 20.85 μs | 1.14 μs | 11.7188 | 1.9531 | - | 209.67 KB | -| GHESYaml | 831,169.7 μs | 217,393.05 μs | 11,916.05 μs | 18000.0000 | 10000.0000 | 2000.0000 | 267570.8 KB | -| GHESJson | 367,711.4 μs | 135,955.63 μs | 7,452.19 μs | 9000.0000 | 8000.0000 | 2000.0000 | 140917.06 KB | -| GHESNextYaml | 1,040,243.2 μs | 167,595.29 μs | 9,186.46 μs | 30000.0000 | 11000.0000 | 2000.0000 | 469507.05 KB | -| GHESNextJson | 615,173.6 μs | 143,051.39 μs | 7,841.13 μs | 22000.0000 | 10000.0000 | 2000.0000 | 345247.91 KB | +| Method | Mean | Error | StdDev | Gen0 | Gen1 | Gen2 | Allocated | +|------------- |-------------:|--------------:|-------------:|-----------:|-----------:|----------:|-------------:| +| PetStoreYaml | 345.8 μs | 69.85 μs | 3.83 μs | 78.1250 | 11.7188 | - | 329.19 KB | +| PetStoreJson | 155.7 μs | 1.06 μs | 0.06 μs | 50.7813 | 9.7656 | - | 211.35 KB | +| GHESYaml | 608,273.7 μs | 86,098.51 μs | 4,719.35 μs | 47000.0000 | 14000.0000 | 3000.0000 | 267921.01 KB | +| GHESJson | 325,277.9 μs | 83,983.75 μs | 4,603.43 μs | 23000.0000 | 11000.0000 | 2000.0000 | 141267.53 KB | +| GHESNextYaml | 641,025.5 μs | 220,286.78 μs | 12,074.66 μs | 50000.0000 | 15000.0000 | 3000.0000 | 282745.1 KB | +| GHESNextJson | 362,873.4 μs | 136,951.76 μs | 7,506.79 μs | 26000.0000 | 12000.0000 | 2000.0000 | 158487.98 KB | diff --git a/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.Descriptions-report.csv b/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.Descriptions-report.csv index bb632a223..e9037adf2 100644 --- a/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.Descriptions-report.csv +++ b/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.Descriptions-report.csv @@ -1,7 +1,7 @@ Method,Job,AnalyzeLaunchVariance,EvaluateOverhead,MaxAbsoluteError,MaxRelativeError,MinInvokeCount,MinIterationTime,OutlierMode,Affinity,EnvironmentVariables,Jit,LargeAddressAware,Platform,PowerPlanMode,Runtime,AllowVeryLargeObjects,Concurrent,CpuGroups,Force,HeapAffinitizeMask,HeapCount,NoAffinitize,RetainVm,Server,Arguments,BuildConfiguration,Clock,EngineFactory,NuGetReferences,Toolchain,IsMutator,InvocationCount,IterationCount,IterationTime,LaunchCount,MaxIterationCount,MaxWarmupIterationCount,MemoryRandomization,MinIterationCount,MinWarmupIterationCount,RunStrategy,UnrollFactor,WarmupCount,Mean,Error,StdDev,Gen0,Gen1,Gen2,Allocated -PetStoreYaml,ShortRun,False,Default,Default,Default,Default,Default,Default,1111,Empty,RyuJit,Default,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,569.0 μs,108.17 μs,5.93 μs,19.5313,0.0000,0.0000,327.8 KB -PetStoreJson,ShortRun,False,Default,Default,Default,Default,Default,Default,1111,Empty,RyuJit,Default,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,250.8 μs,20.85 μs,1.14 μs,11.7188,1.9531,0.0000,209.67 KB -GHESYaml,ShortRun,False,Default,Default,Default,Default,Default,Default,1111,Empty,RyuJit,Default,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,"831,169.7 μs","217,393.05 μs","11,916.05 μs",18000.0000,10000.0000,2000.0000,267570.8 KB -GHESJson,ShortRun,False,Default,Default,Default,Default,Default,Default,1111,Empty,RyuJit,Default,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,"367,711.4 μs","135,955.63 μs","7,452.19 μs",9000.0000,8000.0000,2000.0000,140917.06 KB -GHESNextYaml,ShortRun,False,Default,Default,Default,Default,Default,Default,1111,Empty,RyuJit,Default,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,"1,040,243.2 μs","167,595.29 μs","9,186.46 μs",30000.0000,11000.0000,2000.0000,469507.05 KB -GHESNextJson,ShortRun,False,Default,Default,Default,Default,Default,Default,1111,Empty,RyuJit,Default,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,"615,173.6 μs","143,051.39 μs","7,841.13 μs",22000.0000,10000.0000,2000.0000,345247.91 KB +PetStoreYaml,ShortRun,False,Default,Default,Default,Default,Default,Default,111111111111,Empty,RyuJit,Default,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,345.8 μs,69.85 μs,3.83 μs,78.1250,11.7188,0.0000,329.19 KB +PetStoreJson,ShortRun,False,Default,Default,Default,Default,Default,Default,111111111111,Empty,RyuJit,Default,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,155.7 μs,1.06 μs,0.06 μs,50.7813,9.7656,0.0000,211.35 KB +GHESYaml,ShortRun,False,Default,Default,Default,Default,Default,Default,111111111111,Empty,RyuJit,Default,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,"608,273.7 μs","86,098.51 μs","4,719.35 μs",47000.0000,14000.0000,3000.0000,267921.01 KB +GHESJson,ShortRun,False,Default,Default,Default,Default,Default,Default,111111111111,Empty,RyuJit,Default,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,"325,277.9 μs","83,983.75 μs","4,603.43 μs",23000.0000,11000.0000,2000.0000,141267.53 KB +GHESNextYaml,ShortRun,False,Default,Default,Default,Default,Default,Default,111111111111,Empty,RyuJit,Default,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,"641,025.5 μs","220,286.78 μs","12,074.66 μs",50000.0000,15000.0000,3000.0000,282745.1 KB +GHESNextJson,ShortRun,False,Default,Default,Default,Default,Default,Default,111111111111,Empty,RyuJit,Default,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,3,Default,1,Default,Default,Default,Default,Default,Default,16,3,"362,873.4 μs","136,951.76 μs","7,506.79 μs",26000.0000,12000.0000,2000.0000,158487.98 KB diff --git a/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.Descriptions-report.html b/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.Descriptions-report.html index c9feca148..d9edd3657 100644 --- a/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.Descriptions-report.html +++ b/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.Descriptions-report.html @@ -2,7 +2,7 @@ -performance.Descriptions-20260819-014451 +performance.Descriptions-20261113-131950