Skip to content

Commit 15613dc

Browse files
committed
chore: Merge remote-tracking branch 'origin/main' into fix/allow-implicit-conversion-for-openApiAny
2 parents 2a45f4a + a2291cd commit 15613dc

File tree

171 files changed

+1750
-1532
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

171 files changed

+1750
-1532
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ var document = new OpenApiDocument
5555
{
5656
["/pets"] = new OpenApiPathItem
5757
{
58-
Operations = new Dictionary<HttpMethod, OpenApiOperation>
58+
Operations = new()
5959
{
6060
[HttpMethod.Get] = new OpenApiOperation
6161
{

src/Microsoft.OpenApi.Hidi/Extensions/OpenApiExtensibleExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ internal static class OpenApiExtensibleExtensions
1313
/// <param name="extensions">A dictionary of <see cref="IOpenApiExtension"/>.</param>
1414
/// <param name="extensionKey">The key corresponding to the <see cref="IOpenApiExtension"/>.</param>
1515
/// <returns>A <see cref="string"/> value matching the provided extensionKey. Return null when extensionKey is not found. </returns>
16-
internal static string GetExtension(this IDictionary<string, IOpenApiExtension> extensions, string extensionKey)
16+
internal static string GetExtension(this Dictionary<string, IOpenApiExtension> extensions, string extensionKey)
1717
{
1818
if (extensions.TryGetValue(extensionKey, out var value) && value is OpenApiAny { Node: JsonValue castValue } && castValue.TryGetValue<string>(out var stringValue))
1919
{

src/Microsoft.OpenApi.Hidi/Extensions/StringExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public static bool IsEquals(this string? target, string? searchValue, StringComp
3434
/// <param name="target">The target string to split by char. </param>
3535
/// <param name="separator">The char separator.</param>
3636
/// <returns>An <see cref="IList{String}"/> containing substrings.</returns>
37-
public static IList<string> SplitByChar(this string target, char separator)
37+
public static List<string> SplitByChar(this string target, char separator)
3838
{
3939
if (string.IsNullOrWhiteSpace(target))
4040
{

src/Microsoft.OpenApi.Hidi/Formatters/PowerShellFormatter.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public override void Visit(OpenApiOperation operation)
7777
// Order matters. Resolve operationId.
7878
operationId = RemoveHashSuffix(operationId);
7979
if (operationTypeExtension.IsEquals("action") || operationTypeExtension.IsEquals("function"))
80-
operationId = RemoveKeyTypeSegment(operationId, operation.Parameters ?? new List<IOpenApiParameter>());
80+
operationId = RemoveKeyTypeSegment(operationId, operation.Parameters ?? []);
8181
operationId = SingularizeAndDeduplicateOperationId(operationId.SplitByChar('.'));
8282
operationId = ResolveODataCastOperationId(operationId);
8383
operationId = ResolveByRefOperationId(operationId);
@@ -119,7 +119,7 @@ private static string ResolveODataCastOperationId(string operationId)
119119
return match.Success ? $"{match.Groups[1]}{match.Groups[2]}" : operationId;
120120
}
121121

122-
private static string SingularizeAndDeduplicateOperationId(IList<string> operationIdSegments)
122+
private static string SingularizeAndDeduplicateOperationId(List<string> operationIdSegments)
123123
{
124124
var segmentsCount = operationIdSegments.Count;
125125
var lastSegmentIndex = segmentsCount - 1;
@@ -145,7 +145,7 @@ private static string RemoveHashSuffix(string operationId)
145145
return s_hashSuffixRegex.Match(operationId).Value;
146146
}
147147

148-
private static string RemoveKeyTypeSegment(string operationId, IList<IOpenApiParameter> parameters)
148+
private static string RemoveKeyTypeSegment(string operationId, List<IOpenApiParameter> parameters)
149149
{
150150
var segments = operationId.SplitByChar('.');
151151
foreach (var parameter in parameters)
@@ -159,9 +159,9 @@ private static string RemoveKeyTypeSegment(string operationId, IList<IOpenApiPar
159159
return string.Join('.', segments);
160160
}
161161

162-
private static void ResolveFunctionParameters(IList<IOpenApiParameter> parameters)
162+
private static void ResolveFunctionParameters(List<IOpenApiParameter> parameters)
163163
{
164-
foreach (var parameter in parameters.OfType<OpenApiParameter>().Where(static p => p.Content?.Any() ?? false))
164+
foreach (var parameter in parameters.OfType<OpenApiParameter>().Where(static p => p.Content?.Count > 0))
165165
{
166166
// Replace content with a schema object of type array
167167
// for structured or collection-valued function parameters

src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<ItemGroup>
3030
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
3131
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.3" />
32-
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.3" />
32+
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.4" />
3333
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="9.0.3" />
3434
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.2" />
3535
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.13.61">

src/Microsoft.OpenApi.Hidi/StatsVisitor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public override void Visit(IOpenApiSchema schema)
2727

2828
public int HeaderCount { get; set; }
2929

30-
public override void Visit(IDictionary<string, IOpenApiHeader> headers)
30+
public override void Visit(Dictionary<string, IOpenApiHeader> headers)
3131
{
3232
HeaderCount++;
3333
}

src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1414
<PrivateAssets>all</PrivateAssets>
1515
</PackageReference>
16-
<PackageReference Include="Microsoft.Windows.Compatibility" Version="9.0.3" />
16+
<PackageReference Include="Microsoft.Windows.Compatibility" Version="9.0.4" />
1717
</ItemGroup>
1818
<ItemGroup>
1919
<Resource Include="Themes\Metro\HowToApplyTheme.txt" />

src/Microsoft.OpenApi.Workbench/StatsVisitor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public override void Visit(IOpenApiSchema schema)
2727

2828
public int HeaderCount { get; set; }
2929

30-
public override void Visit(IDictionary<string, IOpenApiHeader> headers)
30+
public override void Visit(Dictionary<string, IOpenApiHeader> headers)
3131
{
3232
HeaderCount++;
3333
}

src/Microsoft.OpenApi.YamlReader/OpenApiYamlReader.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,27 @@ public class OpenApiYamlReader : IOpenApiReader
2626

2727
/// <inheritdoc/>
2828
public async Task<ReadResult> ReadAsync(Stream input,
29+
Uri ___location,
2930
OpenApiReaderSettings settings,
3031
CancellationToken cancellationToken = default)
3132
{
3233
if (input is null) throw new ArgumentNullException(nameof(input));
3334
if (input is MemoryStream memoryStream)
3435
{
35-
return Read(memoryStream, settings);
36+
return Read(memoryStream, ___location, settings);
3637
}
3738
else
3839
{
3940
using var preparedStream = new MemoryStream();
4041
await input.CopyToAsync(preparedStream, copyBufferSize, cancellationToken).ConfigureAwait(false);
4142
preparedStream.Position = 0;
42-
return Read(preparedStream, settings);
43+
return Read(preparedStream, ___location, settings);
4344
}
4445
}
4546

4647
/// <inheritdoc/>
4748
public ReadResult Read(MemoryStream input,
49+
Uri ___location,
4850
OpenApiReaderSettings settings)
4951
{
5052
if (input is null) throw new ArgumentNullException(nameof(input));
@@ -74,13 +76,13 @@ public ReadResult Read(MemoryStream input,
7476
};
7577
}
7678

77-
return Read(jsonNode, settings);
79+
return Read(jsonNode, ___location, settings);
7880
}
7981

8082
/// <inheritdoc/>
81-
public static ReadResult Read(JsonNode jsonNode, OpenApiReaderSettings settings)
83+
public static ReadResult Read(JsonNode jsonNode, Uri ___location, OpenApiReaderSettings settings)
8284
{
83-
return _jsonReader.Read(jsonNode, settings);
85+
return _jsonReader.Read(jsonNode, ___location, settings);
8486
}
8587

8688
/// <inheritdoc/>

src/Microsoft.OpenApi/Extensions/OpenApiExtensibleExtensions.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the MIT license.
33

44
using System;
5+
using System.Collections.Generic;
56
using Microsoft.OpenApi.Exceptions;
67
using Microsoft.OpenApi.Interfaces;
78
using Microsoft.OpenApi.Models;
@@ -32,10 +33,8 @@ public static void AddExtension<T>(this T element, string name, IOpenApiExtensio
3233
throw new OpenApiException(string.Format(SRResource.ExtensionFieldNameMustBeginWithXDash, name));
3334
}
3435

35-
if (element.Extensions is not null)
36-
{
37-
element.Extensions[name] = Utils.CheckArgumentNull(any);
38-
}
36+
element.Extensions ??= [];
37+
element.Extensions[name] = Utils.CheckArgumentNull(any);
3938
}
4039
}
4140
}

0 commit comments

Comments
 (0)