Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/Microsoft.OpenApi.Workbench/MainModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
25 changes: 0 additions & 25 deletions src/Microsoft.OpenApi/Reader/OpenApiReaderSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,11 @@

namespace Microsoft.OpenApi.Reader
{
/// <summary>
/// Indicates if and when the reader should convert unresolved references into resolved objects
/// </summary>
public enum ReferenceResolutionSetting
{
/// <summary>
/// Create placeholder objects with an OpenApiReference instance and UnresolvedReference set to true.
/// </summary>
DoNotResolveReferences,
/// <summary>
/// Convert local references to references of valid domain objects.
/// </summary>
ResolveLocalReferences,
/// <summary>
/// ResolveAllReferences effectively means load external references. Will be removed in v2. External references are never "resolved".
/// </summary>
ResolveAllReferences
}

/// <summary>
/// Configuration settings to control how OpenAPI documents are parsed
/// </summary>
public class OpenApiReaderSettings
{
/// <summary>
/// Indicates how references in the source document should be handled.
/// </summary>
/// <remarks>This setting will be going away in the next major version of this library. Use GetEffective on model objects to get resolved references.</remarks>
public ReferenceResolutionSetting ReferenceResolution { get; set; } = ReferenceResolutionSetting.ResolveLocalReferences;

/// <summary>
/// When external references are found, load them into a shared workspace
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;

Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1500,7 +1500,6 @@ namespace Microsoft.OpenApi.Reader
public System.Collections.Generic.Dictionary<string, System.Func<System.Text.Json.Nodes.JsonNode, Microsoft.OpenApi.OpenApiSpecVersion, Microsoft.OpenApi.Interfaces.IOpenApiExtension>> 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() { }
}
Expand Down Expand Up @@ -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
{
Expand Down