Skip to content

Commit

Permalink
chore: adds unit test to prevent regression on discriminator infinite…
Browse files Browse the repository at this point in the history
… loop
  • Loading branch information
baywet committed Nov 26, 2024
1 parent d559594 commit 678ba2b
Showing 1 changed file with 55 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -847,4 +847,59 @@ public void IsOdataPrimitiveBackwardCompatible()
};
Assert.True(schema.IsODataPrimitiveType());
}
[Fact]
public void ReturnsEmptyPropertyNameOnCircularReferences()
{
var entitySchema = new OpenApiSchema
{
Reference = new OpenApiReference
{
Id = "microsoft.graph.entity"
},
Properties = new Dictionary<string, OpenApiSchema>
{
["id"] = new OpenApiSchema
{
Reference = new OpenApiReference
{
Id = "microsoft.graph.entity"
}
}
}
};
var userSchema = new OpenApiSchema
{
Reference = new OpenApiReference
{
Id = "microsoft.graph.user"
},
OneOf =
[
entitySchema,
new OpenApiSchema {
Type = "object",
Properties = new Dictionary<string, OpenApiSchema> {
["firstName"] = new OpenApiSchema {
Reference = new OpenApiReference {
Id = "microsoft.graph.entity"
}
}
}
}
],
Discriminator = new OpenApiDiscriminator
{
Mapping = new Dictionary<string, string>
{
["microsoft.graph.entity"] = "entity",
["microsoft.graph.user"] = "user"
}
}
};
entitySchema.AllOf =
[
userSchema
];
Assert.Empty(userSchema.GetDiscriminatorPropertyName());
}
}

0 comments on commit 678ba2b

Please sign in to comment.