diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml
index 77e92b36a..f381a4303 100644
--- a/.azure-pipelines/ci-build.yml
+++ b/.azure-pipelines/ci-build.yml
@@ -57,10 +57,10 @@ extends:
version: 8.x
# Install the nuget tool.
- - task: NuGetToolInstaller@0
- displayName: 'Use NuGet >=5.2.0'
+ - task: NuGetToolInstaller@1
+ displayName: 'Use NuGet >=6.11.0'
inputs:
- versionSpec: '>=5.2.0'
+ versionSpec: '>=6.11.0'
checkLatest: true
# Build the Product project
diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj
index 21a7f677f..ee760451f 100644
--- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj
+++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj
@@ -39,6 +39,10 @@
+
+
diff --git a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj
index 0a517bbce..83bc1be2e 100644
--- a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj
+++ b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj
@@ -3,7 +3,7 @@
netstandard2.0
latest
true
- 1.6.19
+ 1.6.20
OpenAPI.NET Readers for JSON and YAML documents
true
@@ -18,7 +18,10 @@
-
+
+ all
+
+
diff --git a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj
index 4379c7595..0e7205ef0 100644
--- a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj
+++ b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj
@@ -10,6 +10,8 @@
+
+
diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj
index d889cc760..61680a879 100644
--- a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj
+++ b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj
@@ -3,7 +3,7 @@
netstandard2.0
Latest
true
- 1.6.19
+ 1.6.20
.NET models with JSON and YAML writers for OpenAPI specification
true
@@ -37,6 +37,8 @@
-
+
+ all
+
diff --git a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs
index 201b321f1..745bb3cdb 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;
@@ -48,8 +48,7 @@ public class OpenApiDocument : IOpenApiSerializable, IOpenApiExtensible, IOpenAp
///
/// A declaration of which security mechanisms can be used across the API.
///
- public IList SecurityRequirements { get; set; } =
- new List();
+ public IList SecurityRequirements { get; set; }
///
/// A list of tags used by the specification with additional metadata.
diff --git a/src/Microsoft.OpenApi/Models/OpenApiOperation.cs b/src/Microsoft.OpenApi/Models/OpenApiOperation.cs
index 69054740e..e4bf5cc39 100644
--- a/src/Microsoft.OpenApi/Models/OpenApiOperation.cs
+++ b/src/Microsoft.OpenApi/Models/OpenApiOperation.cs
@@ -91,7 +91,7 @@ public class OpenApiOperation : IOpenApiSerializable, IOpenApiExtensible, IOpenA
/// 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 IList Security { get; set; }
///
/// An alternative server array to service this operation.
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 75c176305..a0689b473 100644
--- a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj
+++ b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj
@@ -13,7 +13,7 @@
-
+
diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs
index ac566bf0d..f91d0db93 100644
--- a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs
+++ b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs
@@ -193,6 +193,7 @@ public void CopiesOverAllReferencedComponentsToTheSubsetDocumentCorrectly()
var targetExamples = subsetOpenApiDocument.Components.Examples;
// Assert
+ Assert.Same(doc.Servers, subsetOpenApiDocument.Servers);
Assert.False(responseHeader.UnresolvedReference);
Assert.False(mediaTypeExample.UnresolvedReference);
Assert.Single(targetHeaders);
diff --git a/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/docWithReusableHeadersAndExamples.yaml b/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/docWithReusableHeadersAndExamples.yaml
index 2f86d7661..3260ea430 100644
--- a/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/docWithReusableHeadersAndExamples.yaml
+++ b/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/docWithReusableHeadersAndExamples.yaml
@@ -2,6 +2,8 @@ openapi: 3.0.1
info:
title: Example with Multiple Operations and Local $refs
version: 1.0.0
+servers:
+- url: https://api.github.com
paths:
/items:
get:
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 3b6f7c76e..ebb063101 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj
+++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj
@@ -23,6 +23,8 @@
+
+
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs
index bb3db096f..a0bfa7c80 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs
@@ -10,6 +10,7 @@
using FluentAssertions;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Exceptions;
+using Microsoft.OpenApi.Extensions;
using Microsoft.OpenApi.Interfaces;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi.Readers.Interface;
@@ -1432,5 +1433,65 @@ public void ParseBasicDocumentWithServerVariableAndNoDefaultShouldFail()
diagnostic.Errors.Should().NotBeEmpty();
}
+
+ [Fact]
+ public void ParseDocumentWithMissingSecuritySchemeDefaultsToNull()
+ {
+ // Arrange
+ var input = @"openapi: 3.0.0
+info:
+ title: test
+ version: ""1.0""
+paths:
+ /test:
+ get:
+ description: description for test path
+ responses:
+ '200':
+ description: test
+components:
+ securitySchemes:
+ apiKey0:
+ type: apiKey,
+ name: x-api-key,
+ in: header";
+
+ // Act && Assert
+ var doc = new OpenApiStringReader().Read(input, out var diagnostic);
+
+ doc.Paths["/test"].Operations[OperationType.Get].Security.Should().BeNull();
+ doc.SecurityRequirements.Should().BeNull();
+ }
+
+ [Fact]
+ public void ParseDocumentWithEmptySecuritySchemeDefaultsToEmptyList()
+ {
+ // Arrange
+ var input = @"openapi: 3.0.0
+info:
+ title: test
+ version: ""1.0""
+paths:
+ /test:
+ get:
+ description: description for test path
+ responses:
+ '200':
+ description: test
+ security: []
+security:
+- apiKey0: []
+components:
+ securitySchemes:
+ apiKey0:
+ type: apiKey,
+ name: x-api-key,
+ in: header";
+
+ // Act && Assert
+ var doc = new OpenApiStringReader().Read(input, out var diagnostic);
+
+ doc.Paths["/test"].Operations[OperationType.Get].Security.Should().BeEmpty();
+ }
}
}
diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj
index 081f70390..9c91a65ab 100644
--- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj
+++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj
@@ -12,10 +12,10 @@
-
+
-
+