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)
288288 ExternalDocs = schema ? . ExternalDocs != null ? new ( schema ? . ExternalDocs ) : null ;
289289 Deprecated = schema ? . Deprecated ?? Deprecated ;
290290 Xml = schema ? . Xml != null ? new ( schema ? . Xml ) : null ;
291+ Extensions = schema ? . Extensions != null ? new Dictionary < string , IOpenApiExtension > ( schema . Extensions ) : null ;
291292 UnresolvedReference = schema ? . UnresolvedReference ?? UnresolvedReference ;
292293 Reference = schema ? . Reference != null ? new ( schema ? . Reference ) : null ;
293294 }
Original file line number Diff line number Diff line change 99using FluentAssertions ;
1010using Microsoft . OpenApi . Any ;
1111using Microsoft . OpenApi . Extensions ;
12+ using Microsoft . OpenApi . Interfaces ;
1213using Microsoft . OpenApi . Models ;
1314using Microsoft . OpenApi . Writers ;
1415using VerifyXunit ;
@@ -479,5 +480,29 @@ public void OpenApiSchemaCopyConstructorSucceeds()
479480 Assert . Equal ( "date" , actualSchema . Format ) ;
480481 Assert . True ( actualSchema . Nullable ) ;
481482 }
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+ }
482507 }
483508}
Original file line number Diff line number Diff line change @@ -1024,6 +1024,8 @@ namespace Microsoft.OpenApi.Models
10241024 Callback = 8,
10251025 [Microsoft.OpenApi.Attributes.Display("tags")]
10261026 Tag = 9,
1027+ [Microsoft.OpenApi.Attributes.Display("paths")]
1028+ Path = 10,
10271029 }
10281030 public class RuntimeExpressionAnyWrapper : Microsoft.OpenApi.Interfaces.IOpenApiElement
10291031 {
You can’t perform that action at this time.
0 commit comments