Skip to content

Commit 9eea9da

Browse files
committed
fix: copy of extensions for schemas
Signed-off-by: Vincent Biret <[email protected]>
1 parent 3e8b864 commit 9eea9da

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/Microsoft.OpenApi.OData.Reader/Generator/OpenApiSchemaGenerator.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,8 @@ public static IDictionary<string, OpenApiSchema> CreateStructuredTypePropertiesS
425425
{
426426
OpenApiSchema propertySchema = context.CreatePropertySchema(property, document);
427427
propertySchema.Description = context.Model.GetDescriptionAnnotation(property);
428-
propertySchema.Extensions ??= new Dictionary<string, IOpenApiExtension>();
428+
// we always want a new copy because it's a reference
429+
propertySchema.Extensions = propertySchema.Extensions is null ? [] : new Dictionary<string, IOpenApiExtension>(propertySchema.Extensions);
429430
propertySchema.Extensions.AddCustomAttributesToExtensions(context, property);
430431
properties.Add(property.Name, propertySchema);
431432
}
@@ -435,7 +436,8 @@ public static IDictionary<string, OpenApiSchema> CreateStructuredTypePropertiesS
435436
{
436437
OpenApiSchema propertySchema = context.CreateEdmTypeSchema(property.Type, document);
437438
propertySchema.Description = context.Model.GetDescriptionAnnotation(property);
438-
propertySchema.Extensions ??= new Dictionary<string, IOpenApiExtension>();
439+
// we always want a new copy because it's a reference
440+
propertySchema.Extensions = propertySchema.Extensions is null ? [] : new Dictionary<string, IOpenApiExtension>(propertySchema.Extensions);
439441
propertySchema.Extensions.AddCustomAttributesToExtensions(context, property);
440442
propertySchema.Extensions.Add(Constants.xMsNavigationProperty, new OpenApiAny(true));
441443
properties.Add(property.Name, propertySchema);

0 commit comments

Comments
 (0)