Skip to content

Commit ad46bdb

Browse files
committed
chore: implement PR feedback
1 parent 5686de4 commit ad46bdb

File tree

51 files changed

+404
-412
lines changed

Some content is hidden

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

51 files changed

+404
-412
lines changed

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: 4 additions & 4 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,7 +159,7 @@ 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
{
164164
foreach (var parameter in parameters.OfType<OpenApiParameter>().Where(static p => p.Content?.Count > 0))
165165
{

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ public interface IOpenApiPathItem : IOpenApiDescribedElement, IOpenApiSummarized
1919
/// <summary>
2020
/// An alternative server array to service all operations in this path.
2121
/// </summary>
22-
public IList<OpenApiServer>? Servers { get; }
22+
public List<OpenApiServer>? Servers { get; }
2323

2424
/// <summary>
2525
/// A list of parameters that are applicable for all the operations described under this path.
2626
/// These parameters can be overridden at the operation level, but cannot be removed there.
2727
/// </summary>
28-
public IList<IOpenApiParameter>? Parameters { get; }
28+
public List<IOpenApiParameter>? Parameters { get; }
2929
}

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,19 +144,19 @@ public interface IOpenApiSchema : IOpenApiDescribedElement, IOpenApiReadOnlyExte
144144
/// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00
145145
/// Inline or referenced schema MUST be of a Schema Object and not a standard JSON Schema.
146146
/// </summary>
147-
public IList<IOpenApiSchema>? AllOf { get; }
147+
public List<IOpenApiSchema>? AllOf { get; }
148148

149149
/// <summary>
150150
/// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00
151151
/// Inline or referenced schema MUST be of a Schema Object and not a standard JSON Schema.
152152
/// </summary>
153-
public IList<IOpenApiSchema>? OneOf { get; }
153+
public List<IOpenApiSchema>? OneOf { get; }
154154

155155
/// <summary>
156156
/// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00
157157
/// Inline or referenced schema MUST be of a Schema Object and not a standard JSON Schema.
158158
/// </summary>
159-
public IList<IOpenApiSchema>? AnyOf { get; }
159+
public List<IOpenApiSchema>? AnyOf { get; }
160160

161161
/// <summary>
162162
/// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00
@@ -167,7 +167,7 @@ public interface IOpenApiSchema : IOpenApiDescribedElement, IOpenApiReadOnlyExte
167167
/// <summary>
168168
/// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00
169169
/// </summary>
170-
public ISet<string>? Required { get; }
170+
public HashSet<string>? Required { get; }
171171

172172
/// <summary>
173173
/// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00
@@ -246,12 +246,12 @@ public interface IOpenApiSchema : IOpenApiDescribedElement, IOpenApiReadOnlyExte
246246
/// To represent examples that cannot be naturally represented in JSON or YAML,
247247
/// a list of values can be used to contain the examples with escaping where necessary.
248248
/// </summary>
249-
public IList<JsonNode>? Examples { get; }
249+
public List<JsonNode>? Examples { get; }
250250

251251
/// <summary>
252252
/// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00
253253
/// </summary>
254-
public IList<JsonNode>? Enum { get; }
254+
public List<JsonNode>? Enum { get; }
255255

256256
/// <summary>
257257
/// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00
@@ -289,5 +289,5 @@ public interface IOpenApiSchema : IOpenApiDescribedElement, IOpenApiReadOnlyExte
289289
/// <summary>
290290
/// Follow JSON Schema definition:https://json-schema.org/draft/2020-12/json-schema-validation#section-6.5.4
291291
/// </summary>
292-
public Dictionary<string, ISet<string>>? DependentRequired { get; }
292+
public Dictionary<string, HashSet<string>>? DependentRequired { get; }
293293
}

src/Microsoft.OpenApi/Models/OpenApiDocument.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public void RegisterComponents()
4949
/// <summary>
5050
/// An array of Server Objects, which provide connectivity information to a target server.
5151
/// </summary>
52-
public IList<OpenApiServer>? Servers { get; set; } = [];
52+
public List<OpenApiServer>? Servers { get; set; } = [];
5353

5454
/// <summary>
5555
/// REQUIRED. The available paths and operations for the API.
@@ -71,13 +71,13 @@ public void RegisterComponents()
7171
/// <summary>
7272
/// A declaration of which security mechanisms can be used across the API.
7373
/// </summary>
74-
public IList<OpenApiSecurityRequirement>? Security { get; set; }
74+
public List<OpenApiSecurityRequirement>? Security { get; set; }
7575

7676
private HashSet<OpenApiTag>? _tags;
7777
/// <summary>
7878
/// A list of tags used by the specification with additional metadata.
7979
/// </summary>
80-
public ISet<OpenApiTag>? Tags
80+
public HashSet<OpenApiTag>? Tags
8181
{
8282
get
8383
{
@@ -132,11 +132,11 @@ public OpenApiDocument(OpenApiDocument? document)
132132
Workspace = document?.Workspace != null ? new(document.Workspace) : null;
133133
Info = document?.Info != null ? new(document.Info) : new OpenApiInfo();
134134
JsonSchemaDialect = document?.JsonSchemaDialect ?? JsonSchemaDialect;
135-
Servers = document?.Servers != null ? new List<OpenApiServer>(document.Servers) : null;
135+
Servers = document?.Servers != null ? [.. document.Servers] : null;
136136
Paths = document?.Paths != null ? new(document.Paths) : [];
137137
Webhooks = document?.Webhooks != null ? new Dictionary<string, IOpenApiPathItem>(document.Webhooks) : null;
138138
Components = document?.Components != null ? new(document?.Components) : null;
139-
Security = document?.Security != null ? new List<OpenApiSecurityRequirement>(document.Security) : null;
139+
Security = document?.Security != null ? [.. document.Security] : null;
140140
Tags = document?.Tags != null ? new HashSet<OpenApiTag>(document.Tags, OpenApiTagComparer.Instance) : null;
141141
ExternalDocs = document?.ExternalDocs != null ? new(document.ExternalDocs) : null;
142142
Extensions = document?.Extensions != null ? new Dictionary<string, IOpenApiExtension>(document.Extensions) : null;
@@ -417,7 +417,7 @@ public void SerializeAsV2(IOpenApiWriter writer)
417417
return server.ReplaceServerUrlVariables([]);
418418
}
419419

420-
private static void WriteHostInfoV2(IOpenApiWriter writer, IList<OpenApiServer>? servers)
420+
private static void WriteHostInfoV2(IOpenApiWriter writer, List<OpenApiServer>? servers)
421421
{
422422
if (servers == null || !servers.Any())
423423
{

src/Microsoft.OpenApi/Models/OpenApiOperation.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class OpenApiOperation : IOpenApiSerializable, IOpenApiExtensible, IMetad
2626
/// A list of tags for API documentation control.
2727
/// Tags can be used for logical grouping of operations by resources or any other qualifier.
2828
/// </summary>
29-
public ISet<OpenApiTagReference>? Tags
29+
public HashSet<OpenApiTagReference>? Tags
3030
{
3131
get
3232
{
@@ -73,7 +73,7 @@ public ISet<OpenApiTagReference>? Tags
7373
/// The list MUST NOT include duplicated parameters. A unique parameter is defined by a combination of a name and location.
7474
/// The list can use the Reference Object to link to parameters that are defined at the OpenAPI Object's components/parameters.
7575
/// </summary>
76-
public IList<IOpenApiParameter>? Parameters { get; set; }
76+
public List<IOpenApiParameter>? Parameters { get; set; }
7777

7878
/// <summary>
7979
/// The request body applicable for this operation.
@@ -110,14 +110,14 @@ public ISet<OpenApiTagReference>? Tags
110110
/// This definition overrides any declared top-level security.
111111
/// To remove a top-level security declaration, an empty array can be used.
112112
/// </summary>
113-
public IList<OpenApiSecurityRequirement>? Security { get; set; }
113+
public List<OpenApiSecurityRequirement>? Security { get; set; }
114114

115115
/// <summary>
116116
/// An alternative server array to service this operation.
117117
/// If an alternative server object is specified at the Path Item Object or Root level,
118118
/// it will be overridden by this value.
119119
/// </summary>
120-
public IList<OpenApiServer>? Servers { get; set; }
120+
public List<OpenApiServer>? Servers { get; set; }
121121

122122
/// <summary>
123123
/// This object MAY be extended with Specification Extensions.
@@ -138,18 +138,18 @@ public OpenApiOperation() { }
138138
public OpenApiOperation(OpenApiOperation operation)
139139
{
140140
Utils.CheckArgumentNull(operation);
141-
Tags = operation.Tags != null ? new HashSet<OpenApiTagReference>(operation.Tags) : null;
141+
Tags = operation.Tags != null ? [.. operation.Tags] : null;
142142
Summary = operation.Summary ?? Summary;
143143
Description = operation.Description ?? Description;
144144
ExternalDocs = operation.ExternalDocs != null ? new(operation.ExternalDocs) : null;
145145
OperationId = operation.OperationId ?? OperationId;
146-
Parameters = operation.Parameters != null ? new List<IOpenApiParameter>(operation.Parameters) : null;
146+
Parameters = operation.Parameters != null ? [.. operation.Parameters] : null;
147147
RequestBody = operation.RequestBody?.CreateShallowCopy();
148148
Responses = operation.Responses != null ? new(operation.Responses) : null;
149149
Callbacks = operation.Callbacks != null ? new Dictionary<string, IOpenApiCallback>(operation.Callbacks) : null;
150150
Deprecated = operation.Deprecated;
151-
Security = operation.Security != null ? new List<OpenApiSecurityRequirement>(operation.Security) : null;
152-
Servers = operation.Servers != null ? new List<OpenApiServer>(operation.Servers) : null;
151+
Security = operation.Security != null ? [.. operation.Security] : null;
152+
Servers = operation.Servers != null ? [.. operation.Servers] : null;
153153
Extensions = operation.Extensions != null ? new Dictionary<string, IOpenApiExtension>(operation.Extensions) : null;
154154
Metadata = operation.Metadata != null ? new Dictionary<string, object>(operation.Metadata) : null;
155155
}

src/Microsoft.OpenApi/Models/OpenApiPathItem.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ public class OpenApiPathItem : IOpenApiExtensible, IOpenApiPathItem
2626
public Dictionary<HttpMethod, OpenApiOperation>? Operations { get; set; }
2727

2828
/// <inheritdoc/>
29-
public IList<OpenApiServer>? Servers { get; set; }
29+
public List<OpenApiServer>? Servers { get; set; }
3030

3131
/// <inheritdoc/>
32-
public IList<IOpenApiParameter>? Parameters { get; set; }
32+
public List<IOpenApiParameter>? Parameters { get; set; }
3333

3434
/// <inheritdoc/>
3535
public Dictionary<string, IOpenApiExtension>? Extensions { get; set; }
@@ -59,8 +59,8 @@ internal OpenApiPathItem(IOpenApiPathItem pathItem)
5959
Summary = pathItem.Summary ?? Summary;
6060
Description = pathItem.Description ?? Description;
6161
Operations = pathItem.Operations != null ? new Dictionary<HttpMethod, OpenApiOperation>(pathItem.Operations) : null;
62-
Servers = pathItem.Servers != null ? new List<OpenApiServer>(pathItem.Servers) : null;
63-
Parameters = pathItem.Parameters != null ? new List<IOpenApiParameter>(pathItem.Parameters) : null;
62+
Servers = pathItem.Servers != null ? [.. pathItem.Servers] : null;
63+
Parameters = pathItem.Parameters != null ? [.. pathItem.Parameters] : null;
6464
Extensions = pathItem.Extensions != null ? new Dictionary<string, IOpenApiExtension>(pathItem.Extensions) : null;
6565
}
6666

src/Microsoft.OpenApi/Models/OpenApiSchema.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -173,19 +173,19 @@ public decimal? Minimum
173173
public bool WriteOnly { get; set; }
174174

175175
/// <inheritdoc />
176-
public IList<IOpenApiSchema>? AllOf { get; set; }
176+
public List<IOpenApiSchema>? AllOf { get; set; }
177177

178178
/// <inheritdoc />
179-
public IList<IOpenApiSchema>? OneOf { get; set; }
179+
public List<IOpenApiSchema>? OneOf { get; set; }
180180

181181
/// <inheritdoc />
182-
public IList<IOpenApiSchema>? AnyOf { get; set; }
182+
public List<IOpenApiSchema>? AnyOf { get; set; }
183183

184184
/// <inheritdoc />
185185
public IOpenApiSchema? Not { get; set; }
186186

187187
/// <inheritdoc />
188-
public ISet<string>? Required { get; set; }
188+
public HashSet<string>? Required { get; set; }
189189

190190
/// <inheritdoc />
191191
public IOpenApiSchema? Items { get; set; }
@@ -224,10 +224,10 @@ public decimal? Minimum
224224
public JsonNode? Example { get; set; }
225225

226226
/// <inheritdoc />
227-
public IList<JsonNode>? Examples { get; set; }
227+
public List<JsonNode>? Examples { get; set; }
228228

229229
/// <inheritdoc />
230-
public IList<JsonNode>? Enum { get; set; }
230+
public List<JsonNode>? Enum { get; set; }
231231

232232
/// <inheritdoc />
233233
public bool UnevaluatedProperties { get; set; }
@@ -251,7 +251,7 @@ public decimal? Minimum
251251
public Dictionary<string, object>? Annotations { get; set; }
252252

253253
/// <inheritdoc />
254-
public Dictionary<string, ISet<string>>? DependentRequired { get; set; }
254+
public Dictionary<string, HashSet<string>>? DependentRequired { get; set; }
255255

256256
/// <summary>
257257
/// Parameterless constructor
@@ -294,11 +294,11 @@ internal OpenApiSchema(IOpenApiSchema schema)
294294
Default = schema.Default != null ? JsonNodeCloneHelper.Clone(schema.Default) : null;
295295
ReadOnly = schema.ReadOnly;
296296
WriteOnly = schema.WriteOnly;
297-
AllOf = schema.AllOf != null ? new List<IOpenApiSchema>(schema.AllOf) : null;
298-
OneOf = schema.OneOf != null ? new List<IOpenApiSchema>(schema.OneOf) : null;
299-
AnyOf = schema.AnyOf != null ? new List<IOpenApiSchema>(schema.AnyOf) : null;
297+
AllOf = schema.AllOf != null ? [.. schema.AllOf] : null;
298+
OneOf = schema.OneOf != null ? [.. schema.OneOf] : null;
299+
AnyOf = schema.AnyOf != null ? [.. schema.AnyOf] : null;
300300
Not = schema.Not?.CreateShallowCopy();
301-
Required = schema.Required != null ? new HashSet<string>(schema.Required) : null;
301+
Required = schema.Required != null ? [.. schema.Required] : null;
302302
Items = schema.Items?.CreateShallowCopy();
303303
MaxItems = schema.MaxItems ?? MaxItems;
304304
MinItems = schema.MinItems ?? MinItems;
@@ -311,15 +311,15 @@ internal OpenApiSchema(IOpenApiSchema schema)
311311
AdditionalProperties = schema.AdditionalProperties?.CreateShallowCopy();
312312
Discriminator = schema.Discriminator != null ? new(schema.Discriminator) : null;
313313
Example = schema.Example != null ? JsonNodeCloneHelper.Clone(schema.Example) : null;
314-
Examples = schema.Examples != null ? new List<JsonNode>(schema.Examples) : null;
315-
Enum = schema.Enum != null ? new List<JsonNode>(schema.Enum) : null;
314+
Examples = schema.Examples != null ? [.. schema.Examples] : null;
315+
Enum = schema.Enum != null ? [.. schema.Enum] : null;
316316
ExternalDocs = schema.ExternalDocs != null ? new(schema.ExternalDocs) : null;
317317
Deprecated = schema.Deprecated;
318318
Xml = schema.Xml != null ? new(schema.Xml) : null;
319319
Extensions = schema.Extensions != null ? new Dictionary<string, IOpenApiExtension>(schema.Extensions) : null;
320320
Annotations = schema.Annotations != null ? new Dictionary<string, object>(schema.Annotations) : null;
321321
UnrecognizedKeywords = schema.UnrecognizedKeywords != null ? new Dictionary<string, JsonNode>(schema.UnrecognizedKeywords) : null;
322-
DependentRequired = schema.DependentRequired != null ? new Dictionary<string, ISet<string>>(schema.DependentRequired) : null;
322+
DependentRequired = schema.DependentRequired != null ? new Dictionary<string, HashSet<string>>(schema.DependentRequired) : null;
323323
}
324324

325325
/// <inheritdoc />
@@ -607,7 +607,7 @@ private void WriteFormatProperty(IOpenApiWriter writer)
607607
/// <param name="propertyName">The property name that will be serialized.</param>
608608
private void SerializeAsV2(
609609
IOpenApiWriter writer,
610-
ISet<string>? parentRequiredProperties,
610+
HashSet<string>? parentRequiredProperties,
611611
string? propertyName)
612612
{
613613
parentRequiredProperties ??= new HashSet<string>();
@@ -844,7 +844,7 @@ where temporaryType.HasFlag(flag)
844844
private static readonly Array jsonSchemaTypeValues = System.Enum.GetValues(typeof(JsonSchemaType));
845845
#endif
846846

847-
private void DowncastTypeArrayToV2OrV3(JsonSchemaType schemaType, IOpenApiWriter writer, OpenApiSpecVersion version)
847+
private static void DowncastTypeArrayToV2OrV3(JsonSchemaType schemaType, IOpenApiWriter writer, OpenApiSpecVersion version)
848848
{
849849
/* If the array has one non-null value, emit Type as string
850850
* If the array has one null value, emit x-nullable as true

src/Microsoft.OpenApi/Models/OpenApiSecurityRequirement.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace Microsoft.OpenApi.Models
1919
/// then the value is a list of scope names required for the execution.
2020
/// For other security scheme types, the array MUST be empty.
2121
/// </summary>
22-
public class OpenApiSecurityRequirement : Dictionary<OpenApiSecuritySchemeReference, IList<string>>,
22+
public class OpenApiSecurityRequirement : Dictionary<OpenApiSecuritySchemeReference, List<string>>,
2323
IOpenApiSerializable
2424
{
2525
/// <summary>

0 commit comments

Comments
 (0)