File tree Expand file tree Collapse file tree 3 files changed +28
-0
lines changed
src/Microsoft.OpenApi/Models
test/Microsoft.OpenApi.Tests Expand file tree Collapse file tree 3 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -288,6 +288,7 @@ public OpenApiSchema(OpenApiSchema schema)
288
288
ExternalDocs = schema ? . ExternalDocs != null ? new ( schema ? . ExternalDocs ) : null ;
289
289
Deprecated = schema ? . Deprecated ?? Deprecated ;
290
290
Xml = schema ? . Xml != null ? new ( schema ? . Xml ) : null ;
291
+ Extensions = schema ? . Extensions != null ? new Dictionary < string , IOpenApiExtension > ( schema . Extensions ) : null ;
291
292
UnresolvedReference = schema ? . UnresolvedReference ?? UnresolvedReference ;
292
293
Reference = schema ? . Reference != null ? new ( schema ? . Reference ) : null ;
293
294
}
Original file line number Diff line number Diff line change 9
9
using FluentAssertions ;
10
10
using Microsoft . OpenApi . Any ;
11
11
using Microsoft . OpenApi . Extensions ;
12
+ using Microsoft . OpenApi . Interfaces ;
12
13
using Microsoft . OpenApi . Models ;
13
14
using Microsoft . OpenApi . Writers ;
14
15
using VerifyXunit ;
@@ -479,5 +480,29 @@ public void OpenApiSchemaCopyConstructorSucceeds()
479
480
Assert . Equal ( "date" , actualSchema . Format ) ;
480
481
Assert . True ( actualSchema . Nullable ) ;
481
482
}
483
+
484
+ [ Fact ]
485
+ public void CloningSchemaExtensionsWorks ( )
486
+ {
487
+ // Arrange
488
+ var schema = new OpenApiSchema
489
+ {
490
+ Extensions =
491
+ {
492
+ { "x-myextension" , new OpenApiInteger ( 42 ) }
493
+ }
494
+ } ;
495
+
496
+ // Act && Assert
497
+ var schemaCopy = new OpenApiSchema ( schema ) ;
498
+ Assert . Equal ( 1 , schemaCopy . Extensions . Count ) ;
499
+
500
+ // Act && Assert
501
+ schemaCopy . Extensions = new Dictionary < string , IOpenApiExtension >
502
+ {
503
+ { "x-myextension" , new OpenApiInteger ( 40 ) }
504
+ } ;
505
+ Assert . NotEqual ( schema . Extensions , schemaCopy . Extensions ) ;
506
+ }
482
507
}
483
508
}
Original file line number Diff line number Diff line change @@ -1024,6 +1024,8 @@ namespace Microsoft.OpenApi.Models
1024
1024
Callback = 8,
1025
1025
[Microsoft.OpenApi.Attributes.Display("tags")]
1026
1026
Tag = 9,
1027
+ [Microsoft.OpenApi.Attributes.Display("paths")]
1028
+ Path = 10,
1027
1029
}
1028
1030
public class RuntimeExpressionAnyWrapper : Microsoft.OpenApi.Interfaces.IOpenApiElement
1029
1031
{
You can’t perform that action at this time.
0 commit comments