File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
src/Microsoft.OpenApi/Models
test/Microsoft.OpenApi.Tests/Models Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -280,7 +280,7 @@ public OpenApiSchema(OpenApiSchema schema)
280
280
MaxProperties = schema ? . MaxProperties ?? MaxProperties ;
281
281
MinProperties = schema ? . MinProperties ?? MinProperties ;
282
282
AdditionalPropertiesAllowed = schema ? . AdditionalPropertiesAllowed ?? AdditionalPropertiesAllowed ;
283
- AdditionalProperties = new ( schema ? . AdditionalProperties ) ;
283
+ AdditionalProperties = schema ? . AdditionalProperties != null ? new ( schema ? . AdditionalProperties ) : null ;
284
284
Discriminator = schema ? . Discriminator != null ? new ( schema ? . Discriminator ) : null ;
285
285
Example = OpenApiAnyCloneHelper . CloneFromCopyConstructor ( schema ? . Example ) ;
286
286
Enum = schema ? . Enum != null ? new List < IOpenApiAny > ( schema . Enum ) : null ;
Original file line number Diff line number Diff line change @@ -463,5 +463,24 @@ public void SerializeAsV2ShouldSetFormatPropertyInParentSchemaIfPresentInChildre
463
463
// Assert
464
464
Assert . Equal ( expectedV2Schema , v2Schema ) ;
465
465
}
466
+
467
+ [ Fact ]
468
+ public void OpenApiSchemaCopyConstructorSucceeds ( )
469
+ {
470
+ var baseSchema = new OpenApiSchema ( )
471
+ {
472
+ Type = "string" ,
473
+ Format = "date"
474
+ } ;
475
+
476
+ var actualSchema = new OpenApiSchema ( baseSchema )
477
+ {
478
+ Nullable = true
479
+ } ;
480
+
481
+ Assert . Equal ( "string" , actualSchema . Type ) ;
482
+ Assert . Equal ( "date" , actualSchema . Format ) ;
483
+ Assert . True ( actualSchema . Nullable ) ;
484
+ }
466
485
}
467
486
}
You can’t perform that action at this time.
0 commit comments