Skip to content

Commit f9b52cd

Browse files
committed
Attempt at fixing sonarcloud virtual call in ctor flag
1 parent 6e65633 commit f9b52cd

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

src/Microsoft.OpenApi/Models/OpenApiHeader.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public OpenApiHeader(OpenApiHeader header)
109109
Style = header?.Style ?? Style;
110110
Explode = header?.Explode ?? Explode;
111111
AllowReserved = header?.AllowReserved ?? AllowReserved;
112-
Schema = InitializeSchema();
112+
Schema = InitializeSchema(header?.Schema);
113113
Example = JsonNodeCloneHelper.Clone(header?.Example);
114114
Examples = header?.Examples != null ? new Dictionary<string, OpenApiExample>(header.Examples) : null;
115115
Content = header?.Content != null ? new Dictionary<string, OpenApiMediaType>(header.Content) : null;
@@ -304,7 +304,7 @@ public void SerializeAsV2WithoutReference(IOpenApiWriter writer)
304304
/// Clone a JSON schema instance
305305
/// </summary>
306306
/// <returns></returns>
307-
protected JsonSchema InitializeSchema()
307+
protected JsonSchema InitializeSchema(JsonSchema schema)
308308
{
309309
return JsonNodeCloneHelper.CloneJsonSchema(Schema);
310310
}

src/Microsoft.OpenApi/Models/OpenApiMediaType.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public OpenApiMediaType() { }
5757
/// </summary>
5858
public OpenApiMediaType(OpenApiMediaType mediaType)
5959
{
60-
Schema = InitializeSchema();
60+
Schema = InitializeSchema(mediaType?.Schema);
6161
Example = JsonNodeCloneHelper.Clone(mediaType?.Example);
6262
Examples = mediaType?.Examples != null ? new Dictionary<string, OpenApiExample>(mediaType.Examples) : null;
6363
Encoding = mediaType?.Encoding != null ? new Dictionary<string, OpenApiEncoding>(mediaType.Encoding) : null;
@@ -120,7 +120,7 @@ public void SerializeAsV2(IOpenApiWriter writer)
120120
/// Clones a JSON schema instance
121121
/// </summary>
122122
/// <returns></returns>
123-
protected JsonSchema InitializeSchema()
123+
protected JsonSchema InitializeSchema(JsonSchema schema)
124124
{
125125
return JsonNodeCloneHelper.CloneJsonSchema(Schema);
126126
}

src/Microsoft.OpenApi/Models/OpenApiParameter.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public OpenApiParameter(OpenApiParameter parameter)
163163
Style = parameter?.Style ?? Style;
164164
Explode = parameter?.Explode ?? Explode;
165165
AllowReserved = parameter?.AllowReserved ?? AllowReserved;
166-
Schema = JsonNodeCloneHelper.CloneJsonSchema(parameter?.Schema);
166+
Schema = InitializeSchema(parameter?.Schema);
167167
Examples = parameter?.Examples != null ? new Dictionary<string, OpenApiExample>(parameter.Examples) : null;
168168
Example = JsonNodeCloneHelper.Clone(parameter?.Example);
169169
Content = parameter?.Content != null ? new Dictionary<string, OpenApiMediaType>(parameter.Content) : null;
@@ -447,6 +447,15 @@ public void SerializeAsV2WithoutReference(IOpenApiWriter writer)
447447

448448
return Style;
449449
}
450+
451+
/// <summary>
452+
/// Clones an instance of a JSON schema
453+
/// </summary>
454+
/// <returns></returns>
455+
protected JsonSchema InitializeSchema(JsonSchema schema)
456+
{
457+
return JsonNodeCloneHelper.CloneJsonSchema(schema);
458+
}
450459
}
451460

452461
/// <summary>

0 commit comments

Comments
 (0)