File tree Expand file tree Collapse file tree 3 files changed +30
-3
lines changed
src/Microsoft.OpenApi/Models Expand file tree Collapse file tree 3 files changed +30
-3
lines changed Original file line number Diff line number Diff line change @@ -109,7 +109,7 @@ public OpenApiHeader(OpenApiHeader header)
109
109
Style = header ? . Style ?? Style ;
110
110
Explode = header ? . Explode ?? Explode ;
111
111
AllowReserved = header ? . AllowReserved ?? AllowReserved ;
112
- Schema = JsonNodeCloneHelper . CloneJsonSchema ( Schema ) ;
112
+ Schema = InitializeSchema ( ) ;
113
113
Example = JsonNodeCloneHelper . Clone ( header ? . Example ) ;
114
114
Examples = header ? . Examples != null ? new Dictionary < string , OpenApiExample > ( header . Examples ) : null ;
115
115
Content = header ? . Content != null ? new Dictionary < string , OpenApiMediaType > ( header . Content ) : null ;
@@ -299,5 +299,14 @@ public void SerializeAsV2WithoutReference(IOpenApiWriter writer)
299
299
300
300
writer . WriteEndObject ( ) ;
301
301
}
302
+
303
+ /// <summary>
304
+ /// Clone a JSON schema instance
305
+ /// </summary>
306
+ /// <returns></returns>
307
+ protected JsonSchema InitializeSchema ( )
308
+ {
309
+ return JsonNodeCloneHelper . CloneJsonSchema ( Schema ) ;
310
+ }
302
311
}
303
312
}
Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ public OpenApiMediaType() { }
57
57
/// </summary>
58
58
public OpenApiMediaType ( OpenApiMediaType mediaType )
59
59
{
60
- Schema = JsonNodeCloneHelper . CloneJsonSchema ( Schema ) ;
60
+ Schema = InitializeSchema ( ) ;
61
61
Example = JsonNodeCloneHelper . Clone ( mediaType ? . Example ) ;
62
62
Examples = mediaType ? . Examples != null ? new Dictionary < string , OpenApiExample > ( mediaType . Examples ) : null ;
63
63
Encoding = mediaType ? . Encoding != null ? new Dictionary < string , OpenApiEncoding > ( mediaType . Encoding ) : null ;
@@ -115,5 +115,14 @@ public void SerializeAsV2(IOpenApiWriter writer)
115
115
{
116
116
// Media type does not exist in V2.
117
117
}
118
+
119
+ /// <summary>
120
+ /// Clones a JSON schema instance
121
+ /// </summary>
122
+ /// <returns></returns>
123
+ protected JsonSchema InitializeSchema ( )
124
+ {
125
+ return JsonNodeCloneHelper . CloneJsonSchema ( Schema ) ;
126
+ }
118
127
}
119
128
}
Original file line number Diff line number Diff line change @@ -163,7 +163,7 @@ public OpenApiParameter(OpenApiParameter parameter)
163
163
Style = parameter ? . Style ?? Style ;
164
164
Explode = parameter ? . Explode ?? Explode ;
165
165
AllowReserved = parameter ? . AllowReserved ?? AllowReserved ;
166
- Schema = JsonNodeCloneHelper . CloneJsonSchema ( Schema ) ;
166
+ Schema = InitializeSchema ( ) ;
167
167
Examples = parameter ? . Examples != null ? new Dictionary < string , OpenApiExample > ( parameter . Examples ) : null ;
168
168
Example = JsonNodeCloneHelper . Clone ( parameter ? . Example ) ;
169
169
Content = parameter ? . Content != null ? new Dictionary < string , OpenApiMediaType > ( parameter . Content ) : null ;
@@ -447,6 +447,15 @@ public void SerializeAsV2WithoutReference(IOpenApiWriter writer)
447
447
448
448
return Style ;
449
449
}
450
+
451
+ /// <summary>
452
+ /// Clones an instance of a JSON schema
453
+ /// </summary>
454
+ /// <returns></returns>
455
+ protected JsonSchema InitializeSchema ( )
456
+ {
457
+ return JsonNodeCloneHelper . CloneJsonSchema ( Schema ) ;
458
+ }
450
459
}
451
460
452
461
/// <summary>
You can’t perform that action at this time.
0 commit comments