Skip to content

Commit 50b06c4

Browse files
committed
chore: fix merge conflict issues
1 parent 2f8ea28 commit 50b06c4

File tree

5 files changed

+40
-66
lines changed

5 files changed

+40
-66
lines changed

src/Microsoft.OpenApi/Models/Interfaces/IOpenApiPathItem.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public interface IOpenApiPathItem : IOpenApiDescribedElement, IOpenApiSummarized
1414
/// <summary>
1515
/// Gets the definition of operations on this path.
1616
/// </summary>
17-
public IDictionary<HttpMethod, OpenApiOperation> Operations { get; }
17+
public IDictionary<HttpMethod, OpenApiOperation>? Operations { get; }
1818

1919
/// <summary>
2020
/// An alternative server array to service all operations in this path.

src/Microsoft.OpenApi/Services/OpenApiFilterService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public static Func<string, HttpMethod, OpenApiOperation, bool> CreatePredicate(
4242
{
4343
predicate = GetTagsPredicate(tags);
4444
}
45-
else if (requestUrls != null)
45+
else if (requestUrls != null && source is not null)
4646
{
4747
predicate = GetRequestUrlsPredicate(requestUrls, source);
4848
}
@@ -151,7 +151,7 @@ public static OpenApiUrlTreeNode CreateOpenApiUrlTreeNode(Dictionary<string, Ope
151151
return rootNode;
152152
}
153153

154-
private static IDictionary<HttpMethod, OpenApiOperation> GetOpenApiOperations(OpenApiUrlTreeNode rootNode, string relativeUrl, string label)
154+
private static IDictionary<HttpMethod, OpenApiOperation>? GetOpenApiOperations(OpenApiUrlTreeNode rootNode, string relativeUrl, string label)
155155
{
156156
if (relativeUrl.Equals("/", StringComparison.Ordinal) && rootNode.HasOperations(label))
157157
{

src/Microsoft.OpenApi/Services/OpenApiWalker.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1269,7 +1269,7 @@ public class CurrentKeys
12691269
/// <summary>
12701270
/// Current Operation Type
12711271
/// </summary>
1272-
public HttpMethod Operation { get; set; }
1272+
public HttpMethod? Operation { get; set; }
12731273

12741274
/// <summary>
12751275
/// Current Response Status Code

test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs

Lines changed: 8 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ public void TestPredicateFiltersUsingRelativeRequestUrls()
104104
var predicate = OpenApiFilterService.CreatePredicate(requestUrls: requestUrls, source: openApiDocument);
105105

106106
// Then
107-
Assert.True(predicate("/foo", HttpMethod.Get, null));
108-
Assert.True(predicate("/foo", HttpMethod.Post, null));
109-
Assert.False(predicate("/foo", HttpMethod.Patch, null));
107+
Assert.True(predicate("/foo", HttpMethod.Get, null!));
108+
Assert.True(predicate("/foo", HttpMethod.Post, null!));
109+
Assert.False(predicate("/foo", HttpMethod.Patch, null!));
110110
}
111111

112112
[Fact]
@@ -239,45 +239,19 @@ public async Task CopiesOverAllReferencedComponentsToTheSubsetDocumentCorrectly(
239239
var settings = new OpenApiReaderSettings();
240240
settings.AddYamlReader();
241241
var doc = (await OpenApiDocument.LoadAsync(stream, "yaml", settings)).Document;
242-
242+
243243
// validated the tags are read as references
244244
var openApiOperationTags = doc?.Paths["/items"].Operations?[HttpMethod.Get].Tags?.ToArray();
245245
Assert.NotNull(openApiOperationTags);
246246
Assert.Single(openApiOperationTags);
247247
Assert.True(openApiOperationTags[0].UnresolvedReference);
248-
249-
var predicate = OpenApiFilterService.CreatePredicate(operationIds: operationIds);
250-
var subsetOpenApiDocument = OpenApiFilterService.CreateFilteredDocument(doc, predicate);
251-
252-
var response = subsetOpenApiDocument.Paths["/items"].Operations[HttpMethod.Get]?.Responses?["200"];
253-
var responseHeader = response?.Headers["x-custom-header"];
254-
var mediaTypeExample = response?.Content["application/json"]?.Examples?.First().Value;
255-
var targetHeaders = subsetOpenApiDocument.Components?.Headers;
256-
var targetExamples = subsetOpenApiDocument.Components?.Examples;
257248

258-
// Assert
259-
Assert.Same(doc.Servers, subsetOpenApiDocument.Servers);
260-
var headerReference = Assert.IsType<OpenApiHeaderReference>(responseHeader);
261-
Assert.False(headerReference.UnresolvedReference);
262-
var exampleReference = Assert.IsType<OpenApiExampleReference>(mediaTypeExample);
263-
Assert.False(exampleReference?.UnresolvedReference);
264-
Assert.NotNull(targetHeaders);
265-
Assert.Single(targetHeaders);
266-
Assert.NotNull(targetExamples);
267-
Assert.Single(targetExamples);
268-
// validated the tags of the trimmed document are read as references
269-
var trimmedOpenApiOperationTags = subsetOpenApiDocument.Paths["/items"].Operations[HttpMethod.Get].Tags?.ToArray();
270-
Assert.NotNull(trimmedOpenApiOperationTags);
271-
Assert.Single(trimmedOpenApiOperationTags);
272-
Assert.True(trimmedOpenApiOperationTags[0].UnresolvedReference);
273-
274-
// Finally try to write the trimmed document as v3 document
275-
var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture);
276-
var writer = new OpenApiJsonWriter(outputStringWriter)
249+
var predicate = OpenApiFilterService.CreatePredicate(operationIds: operationIds);
250+
if (doc is not null)
277251
{
278252
var subsetOpenApiDocument = OpenApiFilterService.CreateFilteredDocument(doc, predicate);
279253

280-
var response = subsetOpenApiDocument.Paths["/items"].Operations?[OperationType.Get]?.Responses?["200"];
254+
var response = subsetOpenApiDocument.Paths?["/items"].Operations?[HttpMethod.Get]?.Responses?["200"];
281255
var responseHeader = response?.Headers?["x-custom-header"];
282256
var mediaTypeExample = response?.Content?["application/json"]?.Examples?.First().Value;
283257
var targetHeaders = subsetOpenApiDocument.Components?.Headers;
@@ -294,7 +268,7 @@ public async Task CopiesOverAllReferencedComponentsToTheSubsetDocumentCorrectly(
294268
Assert.NotNull(targetExamples);
295269
Assert.Single(targetExamples);
296270
// validated the tags of the trimmed document are read as references
297-
var trimmedOpenApiOperationTags = subsetOpenApiDocument.Paths["/items"].Operations?[OperationType.Get].Tags?.ToArray();
271+
var trimmedOpenApiOperationTags = subsetOpenApiDocument.Paths?["/items"].Operations?[HttpMethod.Get].Tags?.ToArray();
298272
Assert.NotNull(trimmedOpenApiOperationTags);
299273
Assert.Single(trimmedOpenApiOperationTags);
300274
Assert.True(trimmedOpenApiOperationTags[0].UnresolvedReference);

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

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -389,9 +389,9 @@ namespace Microsoft.OpenApi.Models.Interfaces
389389
}
390390
public interface IOpenApiPathItem : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable<Microsoft.OpenApi.Models.Interfaces.IOpenApiPathItem>, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiSummarizedElement
391391
{
392-
System.Collections.Generic.IDictionary<System.Net.Http.HttpMethod, Microsoft.OpenApi.Models.OpenApiOperation> Operations { get; }
393-
System.Collections.Generic.IList<Microsoft.OpenApi.Models.Interfaces.IOpenApiParameter> Parameters { get; }
394-
System.Collections.Generic.IList<Microsoft.OpenApi.Models.OpenApiServer> Servers { get; }
392+
System.Collections.Generic.IDictionary<System.Net.Http.HttpMethod, Microsoft.OpenApi.Models.OpenApiOperation>? Operations { get; }
393+
System.Collections.Generic.IList<Microsoft.OpenApi.Models.Interfaces.IOpenApiParameter>? Parameters { get; }
394+
System.Collections.Generic.IList<Microsoft.OpenApi.Models.OpenApiServer>? Servers { get; }
395395
}
396396
public interface IOpenApiReadOnlyDescribedElement : Microsoft.OpenApi.Interfaces.IOpenApiElement
397397
{
@@ -943,12 +943,12 @@ namespace Microsoft.OpenApi.Models
943943
public class OpenApiPathItem : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable<Microsoft.OpenApi.Models.Interfaces.IOpenApiPathItem>, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiPathItem, Microsoft.OpenApi.Models.Interfaces.IOpenApiSummarizedElement
944944
{
945945
public OpenApiPathItem() { }
946-
public string Description { get; set; }
947-
public System.Collections.Generic.IDictionary<string, Microsoft.OpenApi.Interfaces.IOpenApiExtension> Extensions { get; set; }
948-
public System.Collections.Generic.IDictionary<System.Net.Http.HttpMethod, Microsoft.OpenApi.Models.OpenApiOperation> Operations { get; set; }
949-
public System.Collections.Generic.IList<Microsoft.OpenApi.Models.Interfaces.IOpenApiParameter> Parameters { get; set; }
950-
public System.Collections.Generic.IList<Microsoft.OpenApi.Models.OpenApiServer> Servers { get; set; }
951-
public string Summary { get; set; }
946+
public string? Description { get; set; }
947+
public System.Collections.Generic.IDictionary<string, Microsoft.OpenApi.Interfaces.IOpenApiExtension>? Extensions { get; set; }
948+
public System.Collections.Generic.IDictionary<System.Net.Http.HttpMethod, Microsoft.OpenApi.Models.OpenApiOperation>? Operations { get; set; }
949+
public System.Collections.Generic.IList<Microsoft.OpenApi.Models.Interfaces.IOpenApiParameter>? Parameters { get; set; }
950+
public System.Collections.Generic.IList<Microsoft.OpenApi.Models.OpenApiServer>? Servers { get; set; }
951+
public string? Summary { get; set; }
952952
public void AddOperation(System.Net.Http.HttpMethod operationType, Microsoft.OpenApi.Models.OpenApiOperation operation) { }
953953
public Microsoft.OpenApi.Models.Interfaces.IOpenApiPathItem CreateShallowCopy() { }
954954
public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { }
@@ -1309,13 +1309,13 @@ namespace Microsoft.OpenApi.Models.References
13091309
}
13101310
public class OpenApiPathItemReference : Microsoft.OpenApi.Models.References.BaseOpenApiReferenceHolder<Microsoft.OpenApi.Models.OpenApiPathItem, Microsoft.OpenApi.Models.Interfaces.IOpenApiPathItem>, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable<Microsoft.OpenApi.Models.Interfaces.IOpenApiPathItem>, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiPathItem, Microsoft.OpenApi.Models.Interfaces.IOpenApiSummarizedElement
13111311
{
1312-
public OpenApiPathItemReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument hostDocument = null, string externalResource = null) { }
1313-
public string Description { get; set; }
1314-
public System.Collections.Generic.IDictionary<string, Microsoft.OpenApi.Interfaces.IOpenApiExtension> Extensions { get; }
1315-
public System.Collections.Generic.IDictionary<System.Net.Http.HttpMethod, Microsoft.OpenApi.Models.OpenApiOperation> Operations { get; }
1316-
public System.Collections.Generic.IList<Microsoft.OpenApi.Models.Interfaces.IOpenApiParameter> Parameters { get; }
1317-
public System.Collections.Generic.IList<Microsoft.OpenApi.Models.OpenApiServer> Servers { get; }
1318-
public string Summary { get; set; }
1312+
public OpenApiPathItemReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument? hostDocument = null, string? externalResource = null) { }
1313+
public string? Description { get; set; }
1314+
public System.Collections.Generic.IDictionary<string, Microsoft.OpenApi.Interfaces.IOpenApiExtension>? Extensions { get; }
1315+
public System.Collections.Generic.IDictionary<System.Net.Http.HttpMethod, Microsoft.OpenApi.Models.OpenApiOperation>? Operations { get; }
1316+
public System.Collections.Generic.IList<Microsoft.OpenApi.Models.Interfaces.IOpenApiParameter>? Parameters { get; }
1317+
public System.Collections.Generic.IList<Microsoft.OpenApi.Models.OpenApiServer>? Servers { get; }
1318+
public string? Summary { get; set; }
13191319
public override Microsoft.OpenApi.Models.Interfaces.IOpenApiPathItem CopyReferenceAsTargetElementWithOverrides(Microsoft.OpenApi.Models.Interfaces.IOpenApiPathItem source) { }
13201320
public Microsoft.OpenApi.Models.Interfaces.IOpenApiPathItem CreateShallowCopy() { }
13211321
public override void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { }
@@ -1535,17 +1535,17 @@ namespace Microsoft.OpenApi.Services
15351535
public class CurrentKeys
15361536
{
15371537
public CurrentKeys() { }
1538-
public string Callback { get; set; }
1539-
public string Content { get; set; }
1540-
public string Encoding { get; }
1541-
public string Example { get; }
1542-
public string Extension { get; }
1543-
public string Header { get; }
1544-
public string Link { get; set; }
1545-
public System.Net.Http.HttpMethod Operation { get; set; }
1546-
public string Path { get; set; }
1547-
public string Response { get; set; }
1548-
public string ServerVariable { get; }
1538+
public string? Callback { get; set; }
1539+
public string? Content { get; set; }
1540+
public string? Encoding { get; }
1541+
public string? Example { get; }
1542+
public string? Extension { get; }
1543+
public string? Header { get; }
1544+
public string? Link { get; set; }
1545+
public System.Net.Http.HttpMethod? Operation { get; set; }
1546+
public string? Path { get; set; }
1547+
public string? Response { get; set; }
1548+
public string? ServerVariable { get; }
15491549
}
15501550
public enum MermaidNodeShape
15511551
{
@@ -1564,7 +1564,7 @@ namespace Microsoft.OpenApi.Services
15641564
{
15651565
public static Microsoft.OpenApi.Models.OpenApiDocument CreateFilteredDocument(Microsoft.OpenApi.Models.OpenApiDocument source, System.Func<string, System.Net.Http.HttpMethod, Microsoft.OpenApi.Models.OpenApiOperation, bool> predicate) { }
15661566
public static Microsoft.OpenApi.Services.OpenApiUrlTreeNode CreateOpenApiUrlTreeNode(System.Collections.Generic.Dictionary<string, Microsoft.OpenApi.Models.OpenApiDocument> sources) { }
1567-
public static System.Func<string, System.Net.Http.HttpMethod, Microsoft.OpenApi.Models.OpenApiOperation, bool> CreatePredicate(string operationIds = null, string tags = null, System.Collections.Generic.Dictionary<string, System.Collections.Generic.List<string>> requestUrls = null, Microsoft.OpenApi.Models.OpenApiDocument source = null) { }
1567+
public static System.Func<string, System.Net.Http.HttpMethod, Microsoft.OpenApi.Models.OpenApiOperation, bool> CreatePredicate(string? operationIds = null, string? tags = null, System.Collections.Generic.Dictionary<string, System.Collections.Generic.List<string>>? requestUrls = null, Microsoft.OpenApi.Models.OpenApiDocument? source = null) { }
15681568
}
15691569
public class OpenApiReferenceError : Microsoft.OpenApi.Models.OpenApiError
15701570
{

0 commit comments

Comments
 (0)