Skip to content

Commit 3461332

Browse files
Copilotbaywet
andcommitted
Address code review feedback: use inheritdoc and StringComparer.Ordinal
Co-authored-by: baywet <[email protected]>
1 parent 9928a7b commit 3461332

File tree

1 file changed

+14
-38
lines changed

1 file changed

+14
-38
lines changed

src/Microsoft.OpenApi/Models/OpenApiMediaType.cs

Lines changed: 14 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -13,47 +13,25 @@ namespace Microsoft.OpenApi
1313
/// </summary>
1414
public class OpenApiMediaType : IOpenApiSerializable, IOpenApiExtensible, IOpenApiMediaType
1515
{
16-
/// <summary>
17-
/// The schema defining the type used for the request body.
18-
/// </summary>
16+
/// <inheritdoc />
1917
public IOpenApiSchema? Schema { get; set; }
2018

21-
/// <summary>
22-
/// The schema defining the type used for the items in an array media type.
23-
/// This property is only applicable for OAS 3.2.0 and later.
24-
/// </summary>
19+
/// <inheritdoc />
2520
public IOpenApiSchema? ItemSchema { get; set; }
2621

27-
/// <summary>
28-
/// Example of the media type.
29-
/// The example object SHOULD be in the correct format as specified by the media type.
30-
/// </summary>
22+
/// <inheritdoc />
3123
public JsonNode? Example { get; set; }
3224

33-
/// <summary>
34-
/// Examples of the media type.
35-
/// Each example object SHOULD match the media type and specified schema if present.
36-
/// </summary>
25+
/// <inheritdoc />
3726
public IDictionary<string, IOpenApiExample>? Examples { get; set; }
3827

39-
/// <summary>
40-
/// A map between a property name and its encoding information.
41-
/// The key, being the property name, MUST exist in the schema as a property.
42-
/// The encoding object SHALL only apply to requestBody objects
43-
/// when the media type is multipart or application/x-www-form-urlencoded.
44-
/// </summary>
28+
/// <inheritdoc />
4529
public IDictionary<string, OpenApiEncoding>? Encoding { get; set; }
4630

47-
/// <summary>
48-
/// An encoding object for items in an array schema.
49-
/// Only applies when the schema is of type array.
50-
/// </summary>
31+
/// <inheritdoc />
5132
public OpenApiEncoding? ItemEncoding { get; set; }
5233

53-
/// <summary>
54-
/// An array of encoding objects for prefixItems in an array schema.
55-
/// Each element corresponds to a prefixItem in the schema.
56-
/// </summary>
34+
/// <inheritdoc />
5735
public IList<OpenApiEncoding>? PrefixEncoding { get; set; }
5836

5937
/// <summary>
@@ -74,11 +52,11 @@ public OpenApiMediaType(OpenApiMediaType? mediaType)
7452
Schema = mediaType?.Schema?.CreateShallowCopy();
7553
ItemSchema = mediaType?.ItemSchema?.CreateShallowCopy();
7654
Example = mediaType?.Example != null ? JsonNodeCloneHelper.Clone(mediaType.Example) : null;
77-
Examples = mediaType?.Examples != null ? new Dictionary<string, IOpenApiExample>(mediaType.Examples) : null;
78-
Encoding = mediaType?.Encoding != null ? new Dictionary<string, OpenApiEncoding>(mediaType.Encoding) : null;
55+
Examples = mediaType?.Examples != null ? new Dictionary<string, IOpenApiExample>(mediaType.Examples, StringComparer.Ordinal) : null;
56+
Encoding = mediaType?.Encoding != null ? new Dictionary<string, OpenApiEncoding>(mediaType.Encoding, StringComparer.Ordinal) : null;
7957
ItemEncoding = mediaType?.ItemEncoding != null ? new OpenApiEncoding(mediaType.ItemEncoding) : null;
8058
PrefixEncoding = mediaType?.PrefixEncoding != null ? new List<OpenApiEncoding>(mediaType.PrefixEncoding.Select(e => new OpenApiEncoding(e))) : null;
81-
Extensions = mediaType?.Extensions != null ? new Dictionary<string, IOpenApiExtension>(mediaType.Extensions) : null;
59+
Extensions = mediaType?.Extensions != null ? new Dictionary<string, IOpenApiExtension>(mediaType.Extensions, StringComparer.Ordinal) : null;
8260
}
8361

8462
/// <summary>
@@ -89,16 +67,14 @@ internal OpenApiMediaType(IOpenApiMediaType mediaType)
8967
Schema = mediaType?.Schema?.CreateShallowCopy();
9068
ItemSchema = mediaType?.ItemSchema?.CreateShallowCopy();
9169
Example = mediaType?.Example != null ? JsonNodeCloneHelper.Clone(mediaType.Example) : null;
92-
Examples = mediaType?.Examples != null ? new Dictionary<string, IOpenApiExample>(mediaType.Examples) : null;
93-
Encoding = mediaType?.Encoding != null ? new Dictionary<string, OpenApiEncoding>(mediaType.Encoding) : null;
70+
Examples = mediaType?.Examples != null ? new Dictionary<string, IOpenApiExample>(mediaType.Examples, StringComparer.Ordinal) : null;
71+
Encoding = mediaType?.Encoding != null ? new Dictionary<string, OpenApiEncoding>(mediaType.Encoding, StringComparer.Ordinal) : null;
9472
ItemEncoding = mediaType?.ItemEncoding != null ? new OpenApiEncoding(mediaType.ItemEncoding) : null;
9573
PrefixEncoding = mediaType?.PrefixEncoding != null ? new List<OpenApiEncoding>(mediaType.PrefixEncoding.Select(e => new OpenApiEncoding(e))) : null;
96-
Extensions = mediaType?.Extensions != null ? new Dictionary<string, IOpenApiExtension>(mediaType.Extensions) : null;
74+
Extensions = mediaType?.Extensions != null ? new Dictionary<string, IOpenApiExtension>(mediaType.Extensions, StringComparer.Ordinal) : null;
9775
}
9876

99-
/// <summary>
100-
/// Creates a shallow copy of this <see cref="OpenApiMediaType"/> object
101-
/// </summary>
77+
/// <inheritdoc />
10278
public IOpenApiMediaType CreateShallowCopy()
10379
{
10480
return new OpenApiMediaType(this);

0 commit comments

Comments
 (0)