Prevent duplicate array entries when merging Swagger JSON

This commit is contained in:
Dennis Reimann 2021-10-11 17:29:04 +02:00
parent 25d40972be
commit 5783db9eda
No known key found for this signature in database
GPG Key ID: 5009E1797F03F8D0

View File

@ -92,7 +92,10 @@ namespace BTCPayServer.Controllers
{
await using var stream = fi.CreateReadStream();
using var reader = new StreamReader(fi.CreateReadStream());
json.Merge(JObject.Parse(await reader.ReadToEndAsync()));
json.Merge(JObject.Parse(await reader.ReadToEndAsync()), new JsonMergeSettings
{
MergeArrayHandling = MergeArrayHandling.Union // Prevent duplicates
});
}
var servers = new JArray();
servers.Add(new JObject(new JProperty("url", HttpContext.Request.GetAbsoluteRoot())));