Skip to content

Commit 103ea84

Browse files
authored
Merge pull request #1009 from microsoft/vnext
Merges `vnext` into `master`
2 parents 512c795 + 307d569 commit 103ea84

File tree

8 files changed

+45
-10
lines changed

8 files changed

+45
-10
lines changed

src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<Company>Microsoft</Company>
1111
<Title>Microsoft.OpenApi.Readers</Title>
1212
<PackageId>Microsoft.OpenApi.Readers</PackageId>
13-
<Version>1.4.0</Version>
13+
<Version>1.4.1</Version>
1414
<Description>OpenAPI.NET Readers for JSON and YAML documents</Description>
1515
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
1616
<PackageTags>OpenAPI .NET</PackageTags>

src/Microsoft.OpenApi.Readers/OpenApiYamlDocumentReader.cs

+8-4
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ public OpenApiDocument Read(YamlDocument input, out OpenApiDiagnostic diagnostic
7171
if (_settings.RuleSet != null && _settings.RuleSet.Rules.Count > 0)
7272
{
7373
var openApiErrors = document.Validate(_settings.RuleSet);
74-
foreach (var item in openApiErrors.Where(e => e is OpenApiValidatorError))
74+
foreach (var item in openApiErrors.OfType<OpenApiValidatorError>())
7575
{
7676
diagnostic.Errors.Add(item);
7777
}
78-
foreach (var item in openApiErrors.Where(e => e is OpenApiValidatorWarning))
78+
foreach (var item in openApiErrors.OfType<OpenApiValidatorWarning>())
7979
{
8080
diagnostic.Warnings.Add(item);
8181
}
@@ -114,11 +114,15 @@ public async Task<ReadResult> ReadAsync(YamlDocument input)
114114
// Validate the document
115115
if (_settings.RuleSet != null && _settings.RuleSet.Rules.Count > 0)
116116
{
117-
var errors = document.Validate(_settings.RuleSet);
118-
foreach (var item in errors)
117+
var openApiErrors = document.Validate(_settings.RuleSet);
118+
foreach (var item in openApiErrors.OfType<OpenApiValidatorError>())
119119
{
120120
diagnostic.Errors.Add(item);
121121
}
122+
foreach (var item in openApiErrors.OfType<OpenApiValidatorWarning>())
123+
{
124+
diagnostic.Warnings.Add(item);
125+
}
122126
}
123127

124128
return new ReadResult()

src/Microsoft.OpenApi/Microsoft.OpenApi.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<Company>Microsoft</Company>
1212
<Title>Microsoft.OpenApi</Title>
1313
<PackageId>Microsoft.OpenApi</PackageId>
14-
<Version>1.4.1</Version>
14+
<Version>1.4.2</Version>
1515
<Description>.NET models with JSON and YAML writers for OpenAPI specification</Description>
1616
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
1717
<PackageTags>OpenAPI .NET</PackageTags>

src/Microsoft.OpenApi/Models/OpenApiDocument.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Microsoft Corporation. All rights reserved.
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license.
33

44
using System;

src/Microsoft.OpenApi/Models/OpenApiExtensibleDictionary.cs

+17-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Licensed under the MIT license.
33

44
using System.Collections.Generic;
5-
using Microsoft.OpenApi.Any;
65
using Microsoft.OpenApi.Interfaces;
76
using Microsoft.OpenApi.Writers;
87

@@ -17,6 +16,23 @@ public abstract class OpenApiExtensibleDictionary<T> : Dictionary<string, T>,
1716
IOpenApiExtensible
1817
where T : IOpenApiSerializable
1918
{
19+
/// <summary>
20+
/// Parameterless constructor
21+
/// </summary>
22+
protected OpenApiExtensibleDictionary() { }
23+
24+
/// <summary>
25+
/// Initializes a copy of <see cref="OpenApiExtensibleDictionary{T}"/> class.
26+
/// </summary>
27+
/// <param name="dictionary">The generic dictionary.</param>
28+
/// <param name="extensions">The dictionary of <see cref="IOpenApiExtension"/>.</param>
29+
protected OpenApiExtensibleDictionary(
30+
Dictionary<string, T> dictionary = null,
31+
IDictionary<string, IOpenApiExtension> extensions = null) : base (dictionary)
32+
{
33+
Extensions = extensions != null ? new Dictionary<string, IOpenApiExtension>(extensions) : null;
34+
}
35+
2036
/// <summary>
2137
/// This object MAY be extended with Specification Extensions.
2238
/// </summary>

src/Microsoft.OpenApi/Models/OpenApiPaths.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public OpenApiPaths() {}
1616
/// <summary>
1717
/// Initializes a copy of <see cref="OpenApiPaths"/> object
1818
/// </summary>
19-
public OpenApiPaths(OpenApiPaths paths) {}
20-
19+
/// <param name="paths">The <see cref="OpenApiPaths"/>.</param>
20+
public OpenApiPaths(OpenApiPaths paths) : base(dictionary: paths) {}
2121
}
2222
}

test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs

+14
Original file line numberDiff line numberDiff line change
@@ -1342,5 +1342,19 @@ private static OpenApiDocument ParseInputFile(string filePath)
13421342

13431343
return openApiDoc;
13441344
}
1345+
1346+
[Fact]
1347+
public void CopyConstructorForAdvancedDocumentWorks()
1348+
{
1349+
// Arrange & Act
1350+
var doc = new OpenApiDocument(AdvancedDocument);
1351+
1352+
// Assert
1353+
Assert.NotNull(doc.Info);
1354+
Assert.NotNull(doc.Servers);
1355+
Assert.NotNull(doc.Paths);
1356+
Assert.Equal(2, doc.Paths.Count);
1357+
Assert.NotNull(doc.Components);
1358+
}
13451359
}
13461360
}

test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt

+1
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,7 @@ namespace Microsoft.OpenApi.Models
581581
where T : Microsoft.OpenApi.Interfaces.IOpenApiSerializable
582582
{
583583
protected OpenApiExtensibleDictionary() { }
584+
protected OpenApiExtensibleDictionary(System.Collections.Generic.Dictionary<string, T> dictionary = null, System.Collections.Generic.IDictionary<string, Microsoft.OpenApi.Interfaces.IOpenApiExtension> extensions = null) { }
584585
public System.Collections.Generic.IDictionary<string, Microsoft.OpenApi.Interfaces.IOpenApiExtension> Extensions { get; set; }
585586
public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { }
586587
public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { }

0 commit comments

Comments
 (0)