diff --git a/src/Microsoft.OpenApi.Workbench/MainModel.cs b/src/Microsoft.OpenApi.Workbench/MainModel.cs index 34a44c026..f5c0b2768 100644 --- a/src/Microsoft.OpenApi.Workbench/MainModel.cs +++ b/src/Microsoft.OpenApi.Workbench/MainModel.cs @@ -236,7 +236,6 @@ internal async Task ParseDocumentAsync() var settings = new OpenApiReaderSettings { - ReferenceResolution = ResolveExternal ? ReferenceResolutionSetting.ResolveAllReferences : ReferenceResolutionSetting.ResolveLocalReferences, RuleSet = ValidationRuleSet.GetDefaultRuleSet() }; if (ResolveExternal && !string.IsNullOrWhiteSpace(_inputFile)) diff --git a/src/Microsoft.OpenApi/Reader/OpenApiReaderSettings.cs b/src/Microsoft.OpenApi/Reader/OpenApiReaderSettings.cs index 33f03eedb..c1a275009 100644 --- a/src/Microsoft.OpenApi/Reader/OpenApiReaderSettings.cs +++ b/src/Microsoft.OpenApi/Reader/OpenApiReaderSettings.cs @@ -11,36 +11,11 @@ namespace Microsoft.OpenApi.Reader { - /// - /// Indicates if and when the reader should convert unresolved references into resolved objects - /// - public enum ReferenceResolutionSetting - { - /// - /// Create placeholder objects with an OpenApiReference instance and UnresolvedReference set to true. - /// - DoNotResolveReferences, - /// - /// Convert local references to references of valid domain objects. - /// - ResolveLocalReferences, - /// - /// ResolveAllReferences effectively means load external references. Will be removed in v2. External references are never "resolved". - /// - ResolveAllReferences - } - /// /// Configuration settings to control how OpenAPI documents are parsed /// public class OpenApiReaderSettings { - /// - /// Indicates how references in the source document should be handled. - /// - /// This setting will be going away in the next major version of this library. Use GetEffective on model objects to get resolved references. - public ReferenceResolutionSetting ReferenceResolution { get; set; } = ReferenceResolutionSetting.ResolveLocalReferences; - /// /// When external references are found, load them into a shared workspace /// diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs index ea287db5e..83daf329d 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs @@ -1134,12 +1134,7 @@ public async Task HeaderParameterShouldAllowExample() public async Task ParseDocumentWithReferencedSecuritySchemeWorks() { // Act - var settings = new OpenApiReaderSettings - { - ReferenceResolution = ReferenceResolutionSetting.ResolveLocalReferences - }; - - var result = await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, "docWithSecuritySchemeReference.yaml"), settings); + var result = await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, "docWithSecuritySchemeReference.yaml")); var securityScheme = result.Document.Components.SecuritySchemes["OAuth2"]; // Assert @@ -1153,11 +1148,7 @@ public async Task ParseDocumentWithJsonSchemaReferencesWorks() using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "docWithJsonSchema.yaml")); // Act - var settings = new OpenApiReaderSettings - { - ReferenceResolution = ReferenceResolutionSetting.ResolveLocalReferences - }; - var result = await OpenApiDocument.LoadAsync(stream, OpenApiConstants.Yaml, settings); + var result = await OpenApiDocument.LoadAsync(stream, OpenApiConstants.Yaml); var actualSchema = result.Document.Paths["/users/{userId}"].Operations[OperationType.Get].Responses["200"].Content["application/json"].Schema; @@ -1170,11 +1161,7 @@ public async Task ParseDocumentWithJsonSchemaReferencesWorks() public async Task ValidateExampleShouldNotHaveDataTypeMismatch() { // Act - var result = await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, "documentWithDateExampleInSchema.yaml"), new OpenApiReaderSettings - { - ReferenceResolution = ReferenceResolutionSetting.ResolveLocalReferences - - }); + var result = await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, "documentWithDateExampleInSchema.yaml")); // Assert var warnings = result.Diagnostic.Warnings; diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index c1fb18800..cd6b8a4fc 100644 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -1500,7 +1500,6 @@ namespace Microsoft.OpenApi.Reader public System.Collections.Generic.Dictionary> ExtensionParsers { get; set; } public bool LeaveStreamOpen { get; set; } public bool LoadExternalRefs { get; set; } - public Microsoft.OpenApi.Reader.ReferenceResolutionSetting ReferenceResolution { get; set; } public Microsoft.OpenApi.Validations.ValidationRuleSet RuleSet { get; set; } public void AddMicrosoftExtensionParsers() { } } @@ -1535,12 +1534,6 @@ namespace Microsoft.OpenApi.Reader public Microsoft.OpenApi.Models.OpenApiDocument Document { get; set; } public void Deconstruct(out Microsoft.OpenApi.Models.OpenApiDocument document, out Microsoft.OpenApi.Reader.OpenApiDiagnostic diagnostic) { } } - public enum ReferenceResolutionSetting - { - DoNotResolveReferences = 0, - ResolveLocalReferences = 1, - ResolveAllReferences = 2, - } } namespace Microsoft.OpenApi.Reader.ParseNodes {