diff --git a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj
index 3fdbf2b6d..a3227eac0 100644
--- a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj
+++ b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj
@@ -10,7 +10,7 @@
Microsoft
Microsoft.OpenApi.Readers
Microsoft.OpenApi.Readers
- 1.4.0
+ 1.4.1
OpenAPI.NET Readers for JSON and YAML documents
© Microsoft Corporation. All rights reserved.
OpenAPI .NET
diff --git a/src/Microsoft.OpenApi.Readers/OpenApiYamlDocumentReader.cs b/src/Microsoft.OpenApi.Readers/OpenApiYamlDocumentReader.cs
index 3aedafbf1..37113578a 100644
--- a/src/Microsoft.OpenApi.Readers/OpenApiYamlDocumentReader.cs
+++ b/src/Microsoft.OpenApi.Readers/OpenApiYamlDocumentReader.cs
@@ -71,11 +71,11 @@ public OpenApiDocument Read(YamlDocument input, out OpenApiDiagnostic diagnostic
if (_settings.RuleSet != null && _settings.RuleSet.Rules.Count > 0)
{
var openApiErrors = document.Validate(_settings.RuleSet);
- foreach (var item in openApiErrors.Where(e => e is OpenApiValidatorError))
+ foreach (var item in openApiErrors.OfType())
{
diagnostic.Errors.Add(item);
}
- foreach (var item in openApiErrors.Where(e => e is OpenApiValidatorWarning))
+ foreach (var item in openApiErrors.OfType())
{
diagnostic.Warnings.Add(item);
}
@@ -114,11 +114,15 @@ public async Task ReadAsync(YamlDocument input)
// Validate the document
if (_settings.RuleSet != null && _settings.RuleSet.Rules.Count > 0)
{
- var errors = document.Validate(_settings.RuleSet);
- foreach (var item in errors)
+ var openApiErrors = document.Validate(_settings.RuleSet);
+ foreach (var item in openApiErrors.OfType())
{
diagnostic.Errors.Add(item);
}
+ foreach (var item in openApiErrors.OfType())
+ {
+ diagnostic.Warnings.Add(item);
+ }
}
return new ReadResult()
diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj
index fa8bee8bf..3cac5e0b0 100644
--- a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj
+++ b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj
@@ -11,7 +11,7 @@
Microsoft
Microsoft.OpenApi
Microsoft.OpenApi
- 1.4.1
+ 1.4.2
.NET models with JSON and YAML writers for OpenAPI specification
© Microsoft Corporation. All rights reserved.
OpenAPI .NET
diff --git a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs
index 836e45dd8..93d88b310 100644
--- a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs
+++ b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs
@@ -1,4 +1,4 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
+// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
using System;
diff --git a/src/Microsoft.OpenApi/Models/OpenApiExtensibleDictionary.cs b/src/Microsoft.OpenApi/Models/OpenApiExtensibleDictionary.cs
index 0a43255fb..40c26d429 100644
--- a/src/Microsoft.OpenApi/Models/OpenApiExtensibleDictionary.cs
+++ b/src/Microsoft.OpenApi/Models/OpenApiExtensibleDictionary.cs
@@ -2,7 +2,6 @@
// Licensed under the MIT license.
using System.Collections.Generic;
-using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Interfaces;
using Microsoft.OpenApi.Writers;
@@ -17,6 +16,23 @@ public abstract class OpenApiExtensibleDictionary : Dictionary,
IOpenApiExtensible
where T : IOpenApiSerializable
{
+ ///
+ /// Parameterless constructor
+ ///
+ protected OpenApiExtensibleDictionary() { }
+
+ ///
+ /// Initializes a copy of class.
+ ///
+ /// The generic dictionary.
+ /// The dictionary of .
+ protected OpenApiExtensibleDictionary(
+ Dictionary dictionary = null,
+ IDictionary extensions = null) : base (dictionary)
+ {
+ Extensions = extensions != null ? new Dictionary(extensions) : null;
+ }
+
///
/// This object MAY be extended with Specification Extensions.
///
diff --git a/src/Microsoft.OpenApi/Models/OpenApiPaths.cs b/src/Microsoft.OpenApi/Models/OpenApiPaths.cs
index f65ccb9c4..9b48b4908 100644
--- a/src/Microsoft.OpenApi/Models/OpenApiPaths.cs
+++ b/src/Microsoft.OpenApi/Models/OpenApiPaths.cs
@@ -16,7 +16,7 @@ public OpenApiPaths() {}
///
/// Initializes a copy of object
///
- public OpenApiPaths(OpenApiPaths paths) {}
-
+ /// The .
+ public OpenApiPaths(OpenApiPaths paths) : base(dictionary: paths) {}
}
}
diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs
index cd4cc2b5a..89289397f 100644
--- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs
+++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs
@@ -1342,5 +1342,19 @@ private static OpenApiDocument ParseInputFile(string filePath)
return openApiDoc;
}
+
+ [Fact]
+ public void CopyConstructorForAdvancedDocumentWorks()
+ {
+ // Arrange & Act
+ var doc = new OpenApiDocument(AdvancedDocument);
+
+ // Assert
+ Assert.NotNull(doc.Info);
+ Assert.NotNull(doc.Servers);
+ Assert.NotNull(doc.Paths);
+ Assert.Equal(2, doc.Paths.Count);
+ Assert.NotNull(doc.Components);
+ }
}
}
diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt
index 643f2aa5f..15bc8562b 100755
--- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt
+++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt
@@ -581,6 +581,7 @@ namespace Microsoft.OpenApi.Models
where T : Microsoft.OpenApi.Interfaces.IOpenApiSerializable
{
protected OpenApiExtensibleDictionary() { }
+ protected OpenApiExtensibleDictionary(System.Collections.Generic.Dictionary dictionary = null, 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) { }